package com.eeds.service.project.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.eeds.common.constant.ParametersConstants;
import com.eeds.common.constant.RedisConstant;
import com.eeds.common.enums.ProjectStatus;
import com.eeds.common.model.PageInfo;
import com.eeds.common.model.RespEnum;
import com.eeds.common.table.*;
import com.eeds.dao.*;
import com.eeds.date.DateUtil;
import com.eeds.exception.ServerException;
import com.eeds.json.GsonUtil;
import com.eeds.model.project.req.*;
import com.eeds.model.project.res.*;
import com.eeds.para.ParametersUtil;
import com.eeds.redis.StringRedisUtil;
import com.eeds.service.project.ProjectService;
import com.eeds.service.upload.UploadService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

@Service
public class ProjectServiceImpl implements ProjectService {

    @Autowired
    private ProAdminDao proAdminDao;

    @Autowired
    private UploadService uploadService;

    @Autowired
    private ProDrawingReviewDao proDrawingReviewDao;

    @Autowired
    private ProIntervalApprovalDao proIntervalApprovalDao;

    @Autowired
    private SysFilesDao sysFilesDao;

    @Autowired
    private ProApplyDoubleHeavyDao proApplyDoubleHeavyDao;

    @Autowired
    private ProReleaseDoubleHeavyDao proReleaseDoubleHeavyDao;

    @Autowired
    private ProReleaseDoubleHeavyResourcesAssDao proReleaseDoubleHeavyResourcesAssDao;

    @Autowired
    private ProInformDao proInformDao;

    @Autowired
    private ProBlackoutFiringDao proBlackoutFiringDao;

    @Autowired
    private ProReExaminationDao proReExaminationDao;

    @Autowired
    private ProReExaminationResourcesAssDao proReExaminationResourcesAssDao;

    @Autowired
    private ProTransmissionStartupDao proTransmissionStartupDao;

    @Autowired
    private ProTransmissionStartupResourcesAssDao proTransmissionStartupResourcesAssDao;

    @Autowired
    private  ProStatusInfoAssDao proStatusInfoAssDao;

    @Autowired
    private FixedValueInsuredDao fixedValueInsuredDao;

    @Autowired
    private FixedValueInsuredElectricAssDao fixedValueInsuredElectricAssDao;

    @Autowired
    private FixedValueInsuredLineAssDao fixedValueInsuredLineAssDao;

    @Autowired
    private FixedValueInsuredPtAssDao fixedValueInsuredPtAssDao;

    @Autowired
    private FixedValueInsuredTransformerNameplateAssDao fixedValueInsuredTransformerNameplateAssDao;

    @Autowired
    private ProPowerSupplySchemeDao proPowerSupplySchemeDao;

    @Autowired
    private ProPowerSupplySchemeElectricityPriceAssDao proPowerSupplySchemeElectricityPriceAssDao;

    @Autowired
    private ProPowerSupplySchemeMeteringAssDao proPowerSupplySchemeMeteringAssDao;

    @Autowired
    private ProPowerSupplySchemePowerAssDao proPowerSupplySchemePowerAssDao;

    @Autowired
    private ProUserEvaluationDao proUserEvaluationDao;

    @Autowired
    private ProDataArchivingDao proDataArchivingDao;

    @Autowired
    private ProSceneInvestigationDao proSceneInvestigationDao;

    @Autowired
    private StringRedisUtil redisUtil;


    /**
     * 添加项目信息
     *
     * @param reqAddProjectVO
     * @return
     */
    @Override
    @Transactional
    public Integer addProject(ReqAddProjectVO reqAddProjectVO) {
        ProAdminEntity proAdminEntity = new ProAdminEntity();
        proAdminEntity.setCustomerName(reqAddProjectVO.getCustomerName());
        proAdminEntity.setCustomerProvinces(reqAddProjectVO.getCustomerProvinces());
        proAdminEntity.setCustomerCities(reqAddProjectVO.getCustomerCities());
        proAdminEntity.setCustomerCounties(reqAddProjectVO.getCustomerCounties());
        proAdminEntity.setCustomerAddress(reqAddProjectVO.getCustomerAddress());
        proAdminEntity.setCustomerPhone(reqAddProjectVO.getCustomerPhone());
        proAdminEntity.setCustomerContacts(reqAddProjectVO.getCustomerContacts());
        proAdminEntity.setElectricTotalCapacity(reqAddProjectVO.getElectricTotalCapacity());
        proAdminEntity.setVoltageGrade(reqAddProjectVO.getVoltageGrade());
        proAdminEntity.setOneTime(reqAddProjectVO.getOneTime());
        proAdminEntity.setIdxOneOperator(reqAddProjectVO.getIdxOneOperator());
        Date date = DateUtil.nowDate();
        proAdminEntity.setOneStartTime(date);
        proAdminEntity.setOneEndTime(DateUtil.getDateAfter(date,reqAddProjectVO.getOneTime()));
        proAdminEntity.setTwoTime(reqAddProjectVO.getTwoTime());
        proAdminEntity.setIdxTwoOperstor(reqAddProjectVO.getIdxTwoOperator());
        proAdminEntity.setThreeTime(reqAddProjectVO.getThreeTime());
        proAdminEntity.setIdxThreeOperstor(reqAddProjectVO.getIdxThreeOperator());
        proAdminEntity.setFunIntervalApprovalState(reqAddProjectVO.getFunIntervalApprovalState());
        proAdminEntity.setFunDoubleHeavyState(reqAddProjectVO.getFunDoubleHeavyState());
        proAdminEntity.setFunInformState(reqAddProjectVO.getFunInformState());
        proAdminEntity.setFunHighChargeState(reqAddProjectVO.getFunHighChargeState());
        proAdminEntity.setFunFixedValuePresentationState(reqAddProjectVO.getFunFixedValuePresentationState());
        proAdminEntity.setPowerTransmissionTime(reqAddProjectVO.getPowerTransmissionTime());
        proAdminEntity.setCurrentProgress(reqAddProjectVO.getCurrentProgress());
        proAdminEntity.setFileEnd(reqAddProjectVO.getFileEnd());
        proAdminEntity.setFileEndDetailed(reqAddProjectVO.getFileEndDetailed());
        if(!(reqAddProjectVO.getSubmitState() != null && reqAddProjectVO.getSubmitState() == 0)){
            proAdminEntity.setSubmitState(reqAddProjectVO.getSubmitState());
        }
        proAdminEntity.setCustomerSatisfaction(reqAddProjectVO.getCustomerSatisfaction());
        proAdminEntity.setConstructionUnit(reqAddProjectVO.getConstructionUnit());
        proAdminEntity.setCompletionDataTime(reqAddProjectVO.getCompletionDataTime());
        proAdminEntity.setStatus(ProjectStatus.INIT);
        proAdminEntity.setCreateTime(date);
        proAdminEntity.setTransmissionStatus(0);
        proAdminEntity.setUpdateTime(date);
         proAdminDao.insert(proAdminEntity);
        addOrUpdateProStatus(proAdminEntity.getIdProAdmin(),ProjectStatus.INIT.getValue(),reqAddProjectVO.getSubmitState());
        if(reqAddProjectVO.getSubmitState()!= null && reqAddProjectVO.getSubmitState() == 3){
            updateStatus(proAdminEntity.getIdProAdmin());
        }
        return 1;
    }

    /**
     * 修改项目信息
     *
     * @param reqUpdateProjectVO
     * @return
     */
    @Override
    @Transactional
    public Integer updateProject(ReqUpdateProjectVO reqUpdateProjectVO) {
        ProAdminEntity proAdminEntity = new ProAdminEntity();
        proAdminEntity.setCustomerName(reqUpdateProjectVO.getCustomerName());
        proAdminEntity.setCustomerProvinces(reqUpdateProjectVO.getCustomerProvinces());
        proAdminEntity.setCustomerCities(reqUpdateProjectVO.getCustomerCities());
        proAdminEntity.setCustomerCounties(reqUpdateProjectVO.getCustomerCounties());
        proAdminEntity.setCustomerAddress(reqUpdateProjectVO.getCustomerAddress());
        proAdminEntity.setCustomerPhone(reqUpdateProjectVO.getCustomerPhone());
        proAdminEntity.setCustomerContacts(reqUpdateProjectVO.getCustomerContacts());
        proAdminEntity.setElectricTotalCapacity(reqUpdateProjectVO.getElectricTotalCapacity());
        proAdminEntity.setVoltageGrade(reqUpdateProjectVO.getVoltageGrade());
        proAdminEntity.setOneTime(reqUpdateProjectVO.getOneTime());
        proAdminEntity.setIdxOneOperator(reqUpdateProjectVO.getIdxOneOperator());
        Date date = DateUtil.nowDate();
        proAdminEntity.setOneStartTime(date);
        proAdminEntity.setOneEndTime(DateUtil.getDateAfter(date,reqUpdateProjectVO.getOneTime()));
        proAdminEntity.setTwoTime(reqUpdateProjectVO.getTwoTime());
        proAdminEntity.setIdxTwoOperstor(reqUpdateProjectVO.getIdxTwoOperator());
        proAdminEntity.setThreeTime(reqUpdateProjectVO.getThreeTime());
        proAdminEntity.setIdxThreeOperstor(reqUpdateProjectVO.getIdxThreeOperator());
        proAdminEntity.setFunIntervalApprovalState(reqUpdateProjectVO.getFunIntervalApprovalState());
        proAdminEntity.setFunDoubleHeavyState(reqUpdateProjectVO.getFunDoubleHeavyState());
        proAdminEntity.setFunInformState(reqUpdateProjectVO.getFunInformState());
        proAdminEntity.setFunHighChargeState(reqUpdateProjectVO.getFunHighChargeState());
        proAdminEntity.setFunFixedValuePresentationState(reqUpdateProjectVO.getFunFixedValuePresentationState());
        proAdminEntity.setPowerTransmissionTime(reqUpdateProjectVO.getPowerTransmissionTime());
        proAdminEntity.setCurrentProgress(reqUpdateProjectVO.getCurrentProgress());
        proAdminEntity.setFileEnd(reqUpdateProjectVO.getFileEnd());
        proAdminEntity.setFileEndDetailed(reqUpdateProjectVO.getFileEndDetailed());
        proAdminEntity.setSubmitState(reqUpdateProjectVO.getSubmitState());
        proAdminEntity.setCustomerSatisfaction(reqUpdateProjectVO.getCustomerSatisfaction());
        proAdminEntity.setConstructionUnit(reqUpdateProjectVO.getConstructionUnit());
        proAdminEntity.setCompletionDataTime(reqUpdateProjectVO.getCompletionDataTime());
        addOrUpdateProStatus(reqUpdateProjectVO.getIdProAdmin(),ProjectStatus.INIT.getValue(),reqUpdateProjectVO.getSubmitState());
        if(reqUpdateProjectVO.getSubmitState()!= null && reqUpdateProjectVO.getSubmitState() == 3){
            updateStatus(reqUpdateProjectVO.getIdProAdmin());
        }
        if(!(reqUpdateProjectVO.getSubmitState() != null && reqUpdateProjectVO.getSubmitState() == 0)){
            proAdminEntity.setSubmitState(reqUpdateProjectVO.getSubmitState());
        }
        proAdminEntity.setUpdateTime(date);
        proAdminEntity.setTransmissionStatus(reqUpdateProjectVO.getTransmissionStatus());
        proAdminEntity.setIdProAdmin(reqUpdateProjectVO.getIdProAdmin());
         proAdminDao.updateById(proAdminEntity);
        return 1;
    }


    private Integer addOrUpdateProStatus(Long idProAdmin,Integer status,Integer submitState){
        if((submitState != null && submitState != 0)){
            //如果状态值为10  说明为修改内容，将状态值作为3处理
            submitState = submitState == 10 ? 3 : submitState;

            if(status ==null) {
                ProAdminEntity proAdmin  = proAdminDao.selectById(idProAdmin);
                status = proAdmin.getStatus().getValue();
            }
            ProStatusInfoAssEntity wrapper = new ProStatusInfoAssEntity();
            wrapper.setIdxProAdminId(idProAdmin);
            wrapper.setStatus(status);
            ProStatusInfoAssEntity proStatusInfoAss = proStatusInfoAssDao.selectOne(wrapper);
            if(proStatusInfoAss == null){
                ProStatusInfoAssEntity proStatusInfoAssEntity = new ProStatusInfoAssEntity();
                proStatusInfoAssEntity.setIdxProAdminId(idProAdmin);
                proStatusInfoAssEntity.setSubmitState(submitState);
                proStatusInfoAssEntity.setStatus(status);
                Date date  = new Date();
                proStatusInfoAssEntity.setCreateTime(date);
                proStatusInfoAssEntity.setUpdateTine(date);
                proStatusInfoAssDao.insert(proStatusInfoAssEntity);
            }else{
                ProStatusInfoAssEntity proStatusInfoAssEntity = new ProStatusInfoAssEntity();
                proStatusInfoAssEntity.setSubmitState(submitState);
                proStatusInfoAssEntity.setIdProStatusInfoAss(proStatusInfoAss.getIdProStatusInfoAss());
                Date date  = new Date();
                proStatusInfoAssEntity.setUpdateTine(date);
                proStatusInfoAssDao.updateById(proStatusInfoAssEntity);
            }
        }
        return  1;
    }



    private ProStatusInfoAssEntity getProStatus(Long idProAdmin,Integer status){
        ProStatusInfoAssEntity wrapper = new ProStatusInfoAssEntity();
        wrapper.setIdxProAdminId(idProAdmin);
        wrapper.setStatus(status);
        ProStatusInfoAssEntity proStatusInfoAss = proStatusInfoAssDao.selectOne(wrapper);
        if(proStatusInfoAss == null){
            proStatusInfoAss = new ProStatusInfoAssEntity();
            proStatusInfoAss.setIdxProAdminId(idProAdmin);
            proStatusInfoAss.setStatus(status);
            proStatusInfoAss.setSubmitState(0);
        }
        return  proStatusInfoAss;
    }


    private Integer updateStatus(Long idProAdmin){
        ProAdminEntity proAdmin = proAdminDao.selectById(idProAdmin);
        ProAdminEntity proAdminEntity = new ProAdminEntity();
        proAdminEntity.setIdProAdmin(idProAdmin);
        Date date = DateUtil.nowDate();
        switch (proAdmin.getStatus()){
            //第一阶段
            case INIT:
                proAdminEntity.setStatus(ProjectStatus.SCENE_INVESTIGATION);
            break;
            case SCENE_INVESTIGATION  :
                proAdminEntity.setStatus(ProjectStatus.POWER_SUPPLY_SCHEME);
            break;
            case POWER_SUPPLY_SCHEME  :
                proAdminEntity.setStatus(ProjectStatus.DRAWING_EXAMINATION);
            break;
            case DRAWING_EXAMINATION  :
                proAdminEntity.setStatus(ProjectStatus.INTERVAL_APPROVAL);
                proAdminEntity.setTwoStartTime(date);
                proAdminEntity.setTwoEndTime(DateUtil.getDateAfter(date,proAdmin.getTwoTime()));
            break;

            //第二阶段
            case INTERVAL_APPROVAL  :
                proAdminEntity.setStatus(ProjectStatus.APPLICATION_FOR_DOUBLE_NUMBER);
            break;
            case APPLICATION_FOR_DOUBLE_NUMBER  :
                proAdminEntity.setStatus(ProjectStatus.DOUBLE_NUMBERING);
            break;
            case DOUBLE_NUMBERING  :
                proAdminEntity.setStatus(ProjectStatus.INFORM);
            break;
            case INFORM  :
                proAdminEntity.setStatus(ProjectStatus.BLACKOUT_AND_FIRE);
            break;
            case BLACKOUT_AND_FIRE  :
                proAdminEntity.setStatus(ProjectStatus.PROTECTION_FIXED_VALUE_REPORTING);
            break;
            case PROTECTION_FIXED_VALUE_REPORTING  :
                proAdminEntity.setStatus(ProjectStatus.INTERMEDIATE_INSPECTION);
            break;
            case INTERMEDIATE_INSPECTION  :
                proAdminEntity.setStatus(ProjectStatus.COMPLETION_DATA_COLLECTION);
            break;
            case COMPLETION_DATA_COLLECTION  :
                proAdminEntity.setStatus(ProjectStatus.COMPLETION_ACCEPTANCE);
                proAdminEntity.setThreeStartTime(date);
                proAdminEntity.setThreeEndTime(DateUtil.getDateAfter(date,proAdmin.getThreeTime()));
            break;

            //第三阶段
            case COMPLETION_ACCEPTANCE  :
                proAdminEntity.setStatus(ProjectStatus.REEXAMINATION);
            break;
            case REEXAMINATION  :
                proAdminEntity.setStatus(ProjectStatus.POWER_TRANSMISSION_START_UP);
            break;
            case POWER_TRANSMISSION_START_UP  :
                proAdminEntity.setStatus(ProjectStatus.USER_EVALUATION);
            break;
            case USER_EVALUATION  :
                proAdminEntity.setStatus(ProjectStatus.DATA_ARCHIVING);
            break;
            case DATA_ARCHIVING  :
                proAdminEntity.setStatus(ProjectStatus.FINISH);
            break;
            default:
            break;
        }
        proAdminEntity.setSubmitState(0);
        proAdminDao.updateById(proAdminEntity);
        return 1;
    }

    private Integer updateTransmissionStatus(Long idProAdmin) {
        ProAdminEntity proAdminEntity = new ProAdminEntity();
        proAdminEntity.setIdProAdmin(idProAdmin);
        proAdminEntity.setTransmissionStatus(1);
        proAdminEntity.setPowerTransmissionTime(DateUtil.nowDate());
        proAdminDao.updateById(proAdminEntity);
        return 1;
    }

    /**
     * 项目信息列表
     * reqProjectListVO
     *
     * @param reqGetProjectListVO
     * @return
     */

    @Override
    public PageInfo<ResGetProjectListVO> getProjectList(HttpServletRequest request, ReqGetProjectListVO reqGetProjectListVO) {
        //TODO 判断用户角色，如果不是1则进查询改用户的信息
        String userId = redisUtil.get(RedisConstant.USER_ACCESS_TOKEN+
                request.getHeader(ParametersConstants.ACCESS_TOKEN));
        String userRoleAssListJson = redisUtil.get(RedisConstant.USER_ACCESS_ROLE +  userId);
        List<UserRoleAssEntity> userRoleAssList = GsonUtil.jsonToList(userRoleAssListJson, UserRoleAssEntity.class);
        Boolean falg = false;
        for (UserRoleAssEntity userRoleAssEntity : userRoleAssList) {
            if(userRoleAssEntity.getIdxUserRole() != 1L){
                //TODO 判断当前查询的状态
                if(reqGetProjectListVO.getStatus().getValue() > 20 && reqGetProjectListVO.getStatus().getValue() < 24){
                    reqGetProjectListVO.setIdxOneOperator(Long.parseLong(userId));
                }else if(reqGetProjectListVO.getStatus().getValue() > 30 && reqGetProjectListVO.getStatus().getValue() < 39){
                    reqGetProjectListVO.setIdxTwoOperator(Long.parseLong(userId));
                }else if(reqGetProjectListVO.getStatus().getValue() > 40 && reqGetProjectListVO.getStatus().getValue() < 46){
                    reqGetProjectListVO.setIdxThreeOperator(Long.parseLong(userId));
                }
            }
        }

        PageInfo<ResGetProjectListVO> pageInfo = new PageInfo<>(reqGetProjectListVO);
        List<ResGetProjectListVO> list = proAdminDao.getProjectList(pageInfo,reqGetProjectListVO);
        for (ResGetProjectListVO resGetProjectListVO : list) {
            if(reqGetProjectListVO.getStatus()!=null) {
                // TODO 如果当前项目状态大于查询状态，或者查询状态数据中期阶段
                if (resGetProjectListVO.getStatus() >= reqGetProjectListVO.getStatus().getValue()
                        || (resGetProjectListVO.getStatus() > 30 && resGetProjectListVO.getStatus() < 40
                        && ( ProjectStatus.valueOf(reqGetProjectListVO.getStatus().getValue()).equals(ProjectStatus.INTERVAL_APPROVAL)
                        || ProjectStatus.valueOf(reqGetProjectListVO.getStatus().getValue()).equals(ProjectStatus.APPLICATION_FOR_DOUBLE_NUMBER)
                        || ProjectStatus.valueOf(reqGetProjectListVO.getStatus().getValue()).equals(ProjectStatus.DOUBLE_NUMBERING)
                        || ProjectStatus.valueOf(reqGetProjectListVO.getStatus().getValue()).equals(ProjectStatus.INFORM)
                        || ProjectStatus.valueOf(reqGetProjectListVO.getStatus().getValue()).equals(ProjectStatus.BLACKOUT_AND_FIRE)
                        || ProjectStatus.valueOf(reqGetProjectListVO.getStatus().getValue()).equals(ProjectStatus.PROTECTION_FIXED_VALUE_REPORTING)
                        || ProjectStatus.valueOf(reqGetProjectListVO.getStatus().getValue()).equals(ProjectStatus.INTERMEDIATE_INSPECTION)
                        || ProjectStatus.valueOf(reqGetProjectListVO.getStatus().getValue()).equals(ProjectStatus.COMPLETION_DATA_COLLECTION))
                        )) {
                    ProStatusInfoAssEntity proStatusInfoAssEntity = getProStatus(resGetProjectListVO.getIdProAdmin(),
                            reqGetProjectListVO.getStatus().getValue());
                    resGetProjectListVO.setStatus(proStatusInfoAssEntity.getStatus());
                    resGetProjectListVO.setSubmitState(proStatusInfoAssEntity.getSubmitState());
                }
                if (ProjectStatus.valueOf(resGetProjectListVO.getStatus()).equals(ProjectStatus.POWER_SUPPLY_SCHEME)) {
                    ProPowerSupplySchemeEntity proPowerSupplySchemeEntity = new ProPowerSupplySchemeEntity();
                    proPowerSupplySchemeEntity.setIdxProAdmin(resGetProjectListVO.getIdProAdmin());
                    ProPowerSupplySchemeEntity proPowerSupplySchemeEntity1 = proPowerSupplySchemeDao.selectOne(proPowerSupplySchemeEntity);

                    if (ParametersUtil.isNotNull(proPowerSupplySchemeEntity1)) {
                        resGetProjectListVO.setAboutId(proPowerSupplySchemeEntity1.getIdProPowerSupplyScheme());

                        Wrapper<ProPowerSupplySchemeElectricityPriceAssEntity> wrapper = new EntityWrapper<>();
                        wrapper.eq("idx_pro_power_supply_scheme", proPowerSupplySchemeEntity1.getIdProPowerSupplyScheme());
                        resGetProjectListVO.setCount1(proPowerSupplySchemeElectricityPriceAssDao.selectCount(wrapper));

                        Wrapper<ProPowerSupplySchemeMeteringAssEntity> wrapper1 = new EntityWrapper<>();
                        wrapper1.eq("idx_pro_power_supply_scheme", proPowerSupplySchemeEntity1.getIdProPowerSupplyScheme());
                        resGetProjectListVO.setCount2(proPowerSupplySchemeMeteringAssDao.selectCount(wrapper1));

                        Wrapper<ProPowerSupplySchemePowerAssEntity> wrapper2 = new EntityWrapper<>();
                        wrapper2.eq("idx_pro_power_supply_scheme", proPowerSupplySchemeEntity1.getIdProPowerSupplyScheme());
                        resGetProjectListVO.setCount3(proPowerSupplySchemePowerAssDao.selectCount(wrapper2));
                    }

                }
                if (ProjectStatus.valueOf(resGetProjectListVO.getStatus()).equals(ProjectStatus.PROTECTION_FIXED_VALUE_REPORTING)) {
                    FixedValueInsuredEntity fixedValueInsuredEntity = new FixedValueInsuredEntity();
                    fixedValueInsuredEntity.setIdxProAdmin(resGetProjectListVO.getIdProAdmin());
                    FixedValueInsuredEntity fixedValueInsuredEntity1 = fixedValueInsuredDao.selectOne(fixedValueInsuredEntity);

                    if (ParametersUtil.isNotNull(fixedValueInsuredEntity1)) {
                        resGetProjectListVO.setAboutId(fixedValueInsuredEntity1.getIdFixedValueInsured());

                        Wrapper<FixedValueInsuredElectricAssEntity> wrapper = new EntityWrapper<>();
                        wrapper.eq("idx_fixed_value_insured", fixedValueInsuredEntity1.getIdFixedValueInsured());
                        resGetProjectListVO.setCount1(fixedValueInsuredElectricAssDao.selectCount(wrapper));

                        Wrapper<FixedValueInsuredLineAssEntity> wrapper1 = new EntityWrapper<>();
                        wrapper1.eq("idx_fixed_value_insured", fixedValueInsuredEntity1.getIdFixedValueInsured());
                        resGetProjectListVO.setCount2(fixedValueInsuredLineAssDao.selectCount(wrapper1));

                        Wrapper<FixedValueInsuredPtAssEntity> wrapper2 = new EntityWrapper<>();
                        wrapper2.eq("idx_fixed_value_insured", fixedValueInsuredEntity1.getIdFixedValueInsured());
                        resGetProjectListVO.setCount3(fixedValueInsuredPtAssDao.selectCount(wrapper2));

                        Wrapper<FixedValueInsuredTransformerNameplateAssEntity> wrapper3 = new EntityWrapper<>();
                        wrapper3.eq("idx_fixed_value_insured", fixedValueInsuredEntity1.getIdFixedValueInsured());
                        resGetProjectListVO.setCount4(fixedValueInsuredTransformerNameplateAssDao.selectCount(wrapper3));
                    }
                }

            }
        }
        pageInfo.setData(list);
        pageInfo.setTotalResult(proAdminDao.getProjectListTotalCount(reqGetProjectListVO));

        return pageInfo;
    }

    /**
     * 获取项目信息
     *
     * @param reqGetProjectInfoVO
     * @return
     */
    @Override
    public ResGetProjectInfoVO getProjectInfo(ReqGetProjectInfoVO reqGetProjectInfoVO) {
        return proAdminDao.getProjectInfo(reqGetProjectInfoVO);
    }

    /**
     * 删除项目信息
     *
     * @param reqDeleteProjectVO
     * @return
     */
    @Override
    public Integer deleteProject(ReqDeleteProjectVO reqDeleteProjectVO) {
        ProAdminEntity proAdminEntity = new ProAdminEntity();
        proAdminEntity.setIdProAdmin(reqDeleteProjectVO.getIdProAdmin());
        proAdminEntity.setStatus(ProjectStatus.valueOf(0));
        return proAdminDao.updateById(proAdminEntity);
    }

    /**
     * 获取项目时间信息
     *
     * @param reqGetProjectDateInfoVO
     * @return
     */
    @Override
    public ResGetProjectDateInfoVO getProjectDateInfo(ReqGetProjectDateInfoVO reqGetProjectDateInfoVO) {
        ResGetProjectDateInfoVO resGetProjectDateInfoVO = new ResGetProjectDateInfoVO();
        resGetProjectDateInfoVO.setIdProAdmin(reqGetProjectDateInfoVO.getIdProAdmin());
        ProAdminEntity proAdminEntity = proAdminDao.selectById(reqGetProjectDateInfoVO.getIdProAdmin());
        if(reqGetProjectDateInfoVO.getStageType() != null){
            switch (reqGetProjectDateInfoVO.getStageType()){
                case STAGE_ONE:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getOneStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getOneEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getOneEndTime())));
                    break;
                case STAGE_TWO:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getTwoStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getTwoEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getTwoEndTime())));
                    break;
                case STAGE_THREE:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getThreeStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getThreeEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getThreeEndTime())));
                    break;
            }
        }else {
            switch (proAdminEntity.getStatus()) {
                //第一阶段
                case INIT:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getOneStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getOneEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getOneEndTime())));
                    break;
                case SCENE_INVESTIGATION:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getOneStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getOneEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getOneEndTime())));
                    break;
                case POWER_SUPPLY_SCHEME:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getOneStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getOneEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getOneEndTime())));
                    break;
                case DRAWING_EXAMINATION:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getOneStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getOneEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getOneEndTime())));
                    break;

                //第二阶段
                case INTERVAL_APPROVAL:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getTwoStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getTwoEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getTwoEndTime())));
                    break;
                case APPLICATION_FOR_DOUBLE_NUMBER:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getTwoStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getTwoEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getTwoEndTime())));
                    break;
                case DOUBLE_NUMBERING:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getTwoStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getTwoEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getTwoEndTime())));
                    break;
                case INFORM:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getTwoStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getTwoEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getTwoEndTime())));
                    break;
                case BLACKOUT_AND_FIRE:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getTwoStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getTwoEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getTwoEndTime())));
                    break;
                case PROTECTION_FIXED_VALUE_REPORTING:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getTwoStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getTwoEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getTwoEndTime())));
                    break;
                case INTERMEDIATE_INSPECTION:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getTwoStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getTwoEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getTwoEndTime())));
                    break;
                case COMPLETION_DATA_COLLECTION:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getTwoStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getTwoEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getTwoEndTime())));
                    break;

                //第三阶段
                case COMPLETION_ACCEPTANCE:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getThreeStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getThreeEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getThreeEndTime())));
                    break;
                case REEXAMINATION:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getThreeStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getThreeEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getThreeEndTime())));
                    break;
                case POWER_TRANSMISSION_START_UP:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getThreeStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getThreeEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getThreeEndTime())));
                    break;
                case USER_EVALUATION:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getThreeStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getThreeEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getThreeEndTime())));
                    break;
                case DATA_ARCHIVING:
                    resGetProjectDateInfoVO.setStartDate(proAdminEntity.getThreeStartTime());
                    resGetProjectDateInfoVO.setEndDate(proAdminEntity.getThreeEndTime());
                    resGetProjectDateInfoVO.setHaveTime(0 - DateUtil.getDaysInterval(DateUtil.dateToString(proAdminEntity.getThreeEndTime())));
                    break;


                default:
                    break;
            }
        }

        return resGetProjectDateInfoVO;
    }

    /**
     * 添加图纸审查
     *
     * @param reqAddDrawingExaminationVO
     * @return
     */
    @Override
    @Transactional
    public Integer addDrawingExamination(ReqAddDrawingExaminationVO reqAddDrawingExaminationVO) {
        ProDrawingReviewEntity proDrawingReviewEntity = new ProDrawingReviewEntity();
        proDrawingReviewEntity.setIdxProAdmin(reqAddDrawingExaminationVO.getIdProAdmin());
        proDrawingReviewEntity.setIdxUserBaseInfo(reqAddDrawingExaminationVO.getUserId());
        proDrawingReviewEntity.setSummaryMeeting(reqAddDrawingExaminationVO.getSummaryMeeting());
        proDrawingReviewEntity.setStatus(1);
        Date date = new Date();
        proDrawingReviewEntity.setCreateTime(date);
        proDrawingReviewEntity.setUpdateTime(date);
        proDrawingReviewDao.insert(proDrawingReviewEntity);
        uploadService.updateFileStatus(reqAddDrawingExaminationVO.getSummaryMeeting());
        addOrUpdateProStatus(reqAddDrawingExaminationVO.getIdProAdmin(),ProjectStatus.DRAWING_EXAMINATION.getValue(),reqAddDrawingExaminationVO.getSubmitState());
        if(reqAddDrawingExaminationVO.getSubmitState()!=null && reqAddDrawingExaminationVO.getSubmitState() ==3 ){
            updateStatus(reqAddDrawingExaminationVO.getIdProAdmin());
        }else if( !(reqAddDrawingExaminationVO.getSubmitState()!=null && reqAddDrawingExaminationVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqAddDrawingExaminationVO.getSubmitState());
            proAdmin.setIdProAdmin(reqAddDrawingExaminationVO.getIdProAdmin());
            proAdminDao.updateById(proAdmin);
        }
        return 1;
    }

    /**
     * 获取图纸审查
     *
     * @param reqGetDrawingExaminationVO
     * @return
     */
    @Override
    public ResGetDrawingExaminationVO getDrawingExamination(ReqGetDrawingExaminationVO reqGetDrawingExaminationVO) {
        ResGetDrawingExaminationVO resGetDrawingExaminationVO = proDrawingReviewDao.getDrawingExamination(reqGetDrawingExaminationVO);
        ProStatusInfoAssEntity proStatusInfoAssEntity = getProStatus(reqGetDrawingExaminationVO.getIdProAdmin(),
                ProjectStatus.DRAWING_EXAMINATION.getValue());
        resGetDrawingExaminationVO.setStatus(proStatusInfoAssEntity.getStatus());
        resGetDrawingExaminationVO.setSubmitState(proStatusInfoAssEntity.getSubmitState());
        return resGetDrawingExaminationVO;
    }

    /**
     * 修改图纸审查
     *
     * @param reqUpdateDrawingExaminationVO
     * @return
     */
    @Override
    public Integer updateDrawingExamination(ReqUpdateDrawingExaminationVO reqUpdateDrawingExaminationVO) {
        ProDrawingReviewEntity proDrawingReviewEntity = new ProDrawingReviewEntity();
        proDrawingReviewEntity.setIdProDrawingReview(reqUpdateDrawingExaminationVO.getIdProDrawingReview());
        proDrawingReviewEntity.setIdxUserBaseInfo(reqUpdateDrawingExaminationVO.getUserId());
        proDrawingReviewEntity.setSummaryMeeting(reqUpdateDrawingExaminationVO.getSummaryMeeting());
        ProDrawingReviewEntity proDrawingReviewEntity1 = proDrawingReviewDao.selectById(reqUpdateDrawingExaminationVO.getIdProDrawingReview());
        addOrUpdateProStatus(proDrawingReviewEntity1.getIdxProAdmin(),ProjectStatus.DRAWING_EXAMINATION.getValue(),reqUpdateDrawingExaminationVO.getSubmitState());
        if(reqUpdateDrawingExaminationVO.getSubmitState()!=null && reqUpdateDrawingExaminationVO.getSubmitState() ==3 ){
            updateStatus(proDrawingReviewEntity1.getIdxProAdmin());
        }else if( !(reqUpdateDrawingExaminationVO.getSubmitState()!=null && reqUpdateDrawingExaminationVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqUpdateDrawingExaminationVO.getSubmitState());
            proAdmin.setIdProAdmin(proDrawingReviewEntity1.getIdxProAdmin());
            proAdminDao.updateById(proAdmin);
        }
        proDrawingReviewEntity.setStatus(1);
        Date date = new Date();
        proDrawingReviewEntity.setUpdateTime(date);
        proDrawingReviewDao.updateById(proDrawingReviewEntity);
        uploadService.updateFileStatus(reqUpdateDrawingExaminationVO.getSummaryMeeting());
        return 1;
    }

    /**
     * 添加间隔审批
     *
     * @param reqAddIntervalApprovalVO
     * @return
     */
    @Override
    @Transactional
    public Integer addIntervalApproval(ReqAddIntervalApprovalVO reqAddIntervalApprovalVO) {
        ProIntervalApprovalEntity proIntervalApprovalEntity = new ProIntervalApprovalEntity();
        proIntervalApprovalEntity.setIdxProAdmin(reqAddIntervalApprovalVO.getIdxProAdmin());
        proIntervalApprovalEntity.setIdxUserBaseInfo(reqAddIntervalApprovalVO.getUserId());
        proIntervalApprovalEntity.setIdProIntervalApproval(reqAddIntervalApprovalVO.getIntervalApprovalTable());
        proIntervalApprovalEntity.setIntervalApplySingle(reqAddIntervalApprovalVO.getIntervalApplySingle());
        proIntervalApprovalEntity.setIntervalApprovalTable(reqAddIntervalApprovalVO.getIntervalApprovalTable());
        proIntervalApprovalEntity.setLayout(reqAddIntervalApprovalVO.getLayout());
        proIntervalApprovalEntity.setSummaryDocument(reqAddIntervalApprovalVO.getSummaryDocument());
        proIntervalApprovalEntity.setWiringDiagram(reqAddIntervalApprovalVO.getWiringDiagram());
        proIntervalApprovalEntity.setSubmitState(reqAddIntervalApprovalVO.getSubmitState());
        proIntervalApprovalEntity.setStatus(1);
        Date date = new Date();
        proIntervalApprovalEntity.setCreateTime(date);
        proIntervalApprovalEntity.setUpdateTime(date);
        proIntervalApprovalDao.insert(proIntervalApprovalEntity);

        uploadService.updateFileStatus(reqAddIntervalApprovalVO.getIntervalApprovalTable());
        uploadService.updateFileStatus(reqAddIntervalApprovalVO.getIntervalApplySingle());
        uploadService.updateFileStatus(reqAddIntervalApprovalVO.getLayout());
        uploadService.updateFileStatus(reqAddIntervalApprovalVO.getSummaryDocument());
        uploadService.updateFileStatus(reqAddIntervalApprovalVO.getWiringDiagram());

        addOrUpdateProStatus(reqAddIntervalApprovalVO.getIdxProAdmin(),ProjectStatus.INTERVAL_APPROVAL.getValue(),reqAddIntervalApprovalVO.getSubmitState());

        if(reqAddIntervalApprovalVO.getSubmitState()!=null && reqAddIntervalApprovalVO.getSubmitState() ==3 ){
            updateStatus(reqAddIntervalApprovalVO.getIdxProAdmin());
        }else if( !(reqAddIntervalApprovalVO.getSubmitState()!=null && reqAddIntervalApprovalVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqAddIntervalApprovalVO.getSubmitState());
            proAdmin.setIdProAdmin(reqAddIntervalApprovalVO.getIdxProAdmin());
            proAdminDao.updateById(proAdmin);
        }
        return 1;
    }

    /**
     * 修改间隔审批
     *
     * @param reqUpdateIntervalApprovalVO
     * @return
     */
    @Override
    public Integer updateIntervalApproval(ReqUpdateIntervalApprovalVO reqUpdateIntervalApprovalVO) {
        ProIntervalApprovalEntity proIntervalApprovalEntity = new ProIntervalApprovalEntity();
        proIntervalApprovalEntity.setIdxUserBaseInfo(reqUpdateIntervalApprovalVO.getUserId());
        proIntervalApprovalEntity.setIdProIntervalApproval(reqUpdateIntervalApprovalVO.getIdProIntervalApproval());
        proIntervalApprovalEntity.setIntervalApplySingle(reqUpdateIntervalApprovalVO.getIntervalApplySingle());
        proIntervalApprovalEntity.setIntervalApprovalTable(reqUpdateIntervalApprovalVO.getIntervalApprovalTable());
        proIntervalApprovalEntity.setLayout(reqUpdateIntervalApprovalVO.getLayout());
        proIntervalApprovalEntity.setSummaryDocument(reqUpdateIntervalApprovalVO.getSummaryDocument());
        proIntervalApprovalEntity.setWiringDiagram(reqUpdateIntervalApprovalVO.getWiringDiagram());
        proIntervalApprovalEntity.setSubmitState(reqUpdateIntervalApprovalVO.getSubmitState());
        proIntervalApprovalEntity.setStatus(1);
        Date date = new Date();
        proIntervalApprovalEntity.setCreateTime(date);
        proIntervalApprovalEntity.setUpdateTime(date);
        proIntervalApprovalDao.updateById(proIntervalApprovalEntity);

        uploadService.updateFileStatus(reqUpdateIntervalApprovalVO.getIntervalApprovalTable());
        uploadService.updateFileStatus(reqUpdateIntervalApprovalVO.getIntervalApplySingle());
        uploadService.updateFileStatus(reqUpdateIntervalApprovalVO.getLayout());
        uploadService.updateFileStatus(reqUpdateIntervalApprovalVO.getSummaryDocument());
        uploadService.updateFileStatus(reqUpdateIntervalApprovalVO.getWiringDiagram());

        ProIntervalApprovalEntity proIntervalApprovalEntity1 = proIntervalApprovalDao.selectById(reqUpdateIntervalApprovalVO.getIdProIntervalApproval());
        addOrUpdateProStatus(proIntervalApprovalEntity1.getIdxProAdmin(),ProjectStatus.INTERVAL_APPROVAL.getValue(),reqUpdateIntervalApprovalVO.getSubmitState());

        if(reqUpdateIntervalApprovalVO.getSubmitState()!=null && reqUpdateIntervalApprovalVO.getSubmitState() ==3 ){
            updateStatus(proIntervalApprovalEntity1.getIdxProAdmin());
        }else if( !(reqUpdateIntervalApprovalVO.getSubmitState()!=null && reqUpdateIntervalApprovalVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqUpdateIntervalApprovalVO.getSubmitState());
            proAdmin.setIdProAdmin(proIntervalApprovalEntity1.getIdxProAdmin());
            proAdminDao.updateById(proAdmin);
        }



        return 1;
    }

    /**
     * 获取间隔审批信息
     *
     * @param reqGetIntervalApprovalInfoVO
     * @return
     */
    @Override
    public ResGetIntervalApprovalInfoVO getIntervalApprovalInfo(ReqGetIntervalApprovalInfoVO reqGetIntervalApprovalInfoVO) {
        ResGetIntervalApprovalInfoVO resGetIntervalApprovalInfoVO = new ResGetIntervalApprovalInfoVO();

        ProIntervalApprovalEntity wrapper = new ProIntervalApprovalEntity();
        wrapper.setIdxProAdmin(reqGetIntervalApprovalInfoVO.getIdProAdmin());
        ProIntervalApprovalEntity proIntervalApprovalEntity = proIntervalApprovalDao.selectOne(wrapper);

        resGetIntervalApprovalInfoVO.setIdProIntervalApproval(proIntervalApprovalEntity.getIdProIntervalApproval());
        resGetIntervalApprovalInfoVO.setSubmitState(proIntervalApprovalEntity.getSubmitState());

        resGetIntervalApprovalInfoVO.setIntervalApplySingle(proIntervalApprovalEntity.getIntervalApplySingle());
        if(ParametersUtil.isNotNull(proIntervalApprovalEntity.getIntervalApplySingle())){
            SysFilesEntity sysFilesEntityIntervalApplySingle = sysFilesDao.selectById(proIntervalApprovalEntity.getIntervalApplySingle());
            resGetIntervalApprovalInfoVO.setIntervalApplySingleFileName(sysFilesEntityIntervalApplySingle.getFileName());
            resGetIntervalApprovalInfoVO.setIntervalApplySingleFilePath(sysFilesEntityIntervalApplySingle.getFilePath());
            resGetIntervalApprovalInfoVO.setIntervalApplySingleSuffixName(sysFilesEntityIntervalApplySingle.getSuffixName());
        }

        if(ParametersUtil.isNotNull(proIntervalApprovalEntity.getIntervalApprovalTable())) {
            resGetIntervalApprovalInfoVO.setIntervalApprovalTable(proIntervalApprovalEntity.getIntervalApprovalTable());
            SysFilesEntity sysFilesEntityIntervalApprovalTable = sysFilesDao.selectById(proIntervalApprovalEntity.getIntervalApprovalTable());
            resGetIntervalApprovalInfoVO.setIntervalApprovalTableFileName(sysFilesEntityIntervalApprovalTable.getFileName());
            resGetIntervalApprovalInfoVO.setIntervalApprovalTableFilePath(sysFilesEntityIntervalApprovalTable.getFilePath());
            resGetIntervalApprovalInfoVO.setIntervalApprovalTableSuffixName(sysFilesEntityIntervalApprovalTable.getSuffixName());
        }

        if(ParametersUtil.isNotNull(proIntervalApprovalEntity.getLayout())) {
            resGetIntervalApprovalInfoVO.setLayout(proIntervalApprovalEntity.getLayout());
            SysFilesEntity sysFilesEntityLayout = sysFilesDao.selectById(proIntervalApprovalEntity.getLayout());
            resGetIntervalApprovalInfoVO.setLayoutFileName(sysFilesEntityLayout.getFileName());
            resGetIntervalApprovalInfoVO.setLayoutFilePath(sysFilesEntityLayout.getFilePath());
            resGetIntervalApprovalInfoVO.setLayoutSuffixName(sysFilesEntityLayout.getSuffixName());
        }

        if(ParametersUtil.isNotNull(proIntervalApprovalEntity.getSummaryDocument())) {
            resGetIntervalApprovalInfoVO.setSummaryDocument(proIntervalApprovalEntity.getSummaryDocument());
            SysFilesEntity sysFilesEntitySummaryDocument = sysFilesDao.selectById(proIntervalApprovalEntity.getSummaryDocument());
            resGetIntervalApprovalInfoVO.setSummaryDocumentFileName(sysFilesEntitySummaryDocument.getFileName());
            resGetIntervalApprovalInfoVO.setSummaryDocumentFilePath(sysFilesEntitySummaryDocument.getFilePath());
            resGetIntervalApprovalInfoVO.setSummaryDocumentSuffixName(sysFilesEntitySummaryDocument.getSuffixName());
        }


        if(ParametersUtil.isNotNull(proIntervalApprovalEntity.getWiringDiagram())) {
            resGetIntervalApprovalInfoVO.setWiringDiagram(proIntervalApprovalEntity.getWiringDiagram());
            SysFilesEntity sysFilesEntityWiringDiagram = sysFilesDao.selectById(proIntervalApprovalEntity.getWiringDiagram());
            resGetIntervalApprovalInfoVO.setWiringDiagramFileName(sysFilesEntityWiringDiagram.getFileName());
            resGetIntervalApprovalInfoVO.setWiringDiagramFilePath(sysFilesEntityWiringDiagram.getFilePath());
            resGetIntervalApprovalInfoVO.setWiringDiagramSuffixName(sysFilesEntityWiringDiagram.getSuffixName());
        }

        //获取项目状态
        ProStatusInfoAssEntity proStatusInfoAssEntity = getProStatus(reqGetIntervalApprovalInfoVO.getIdProAdmin(),
                ProjectStatus.INTERVAL_APPROVAL.getValue());
        resGetIntervalApprovalInfoVO.setStatus(proStatusInfoAssEntity.getStatus());
        resGetIntervalApprovalInfoVO.setSubmitState(proStatusInfoAssEntity.getSubmitState());

        return resGetIntervalApprovalInfoVO;
    }

    /**
     * 添加申请双重编号
     *
     * @param reqAddApplicationForDoubleNumberVO
     * @return
     */
    @Override
    public Integer addApplicationForDoubleNumber(ReqAddApplicationForDoubleNumberVO reqAddApplicationForDoubleNumberVO) {
        ProApplyDoubleHeavyEntity proApplyDoubleHeavyEntity = new ProApplyDoubleHeavyEntity();
        proApplyDoubleHeavyEntity.setIdxProAdmin(reqAddApplicationForDoubleNumberVO.getIdxProAdmin());
        proApplyDoubleHeavyEntity.setApplyDoubleHeavyState(reqAddApplicationForDoubleNumberVO.getApplyDoubleHeavyState());
        proApplyDoubleHeavyEntity.setIdxUserBaseInfo(reqAddApplicationForDoubleNumberVO.getUserId());
        Date date = new Date();
        proApplyDoubleHeavyEntity.setCreateTime(date);
        proApplyDoubleHeavyEntity.setUpdateTime(date);
        proApplyDoubleHeavyDao.insert(proApplyDoubleHeavyEntity);

        addOrUpdateProStatus(reqAddApplicationForDoubleNumberVO.getIdxProAdmin(),ProjectStatus.APPLICATION_FOR_DOUBLE_NUMBER.getValue(),reqAddApplicationForDoubleNumberVO.getSubmitState());
        if(reqAddApplicationForDoubleNumberVO.getSubmitState()!=null && reqAddApplicationForDoubleNumberVO.getSubmitState() ==3 ){
            updateStatus(reqAddApplicationForDoubleNumberVO.getIdxProAdmin());
        }else if( !(reqAddApplicationForDoubleNumberVO.getSubmitState()!=null && reqAddApplicationForDoubleNumberVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqAddApplicationForDoubleNumberVO.getSubmitState());
            proAdmin.setIdProAdmin(reqAddApplicationForDoubleNumberVO.getIdxProAdmin());
            proAdminDao.updateById(proAdmin);
        }
        return 1;
    }

    /**
     * 修改申请双重编号
     *
     * @param reqUpdateApplicationForDoubleNumberVO
     * @return
     */
    @Override
    public Integer updateApplicationForDoubleNumber(ReqUpdateApplicationForDoubleNumberVO reqUpdateApplicationForDoubleNumberVO) {
        ProApplyDoubleHeavyEntity proApplyDoubleHeavyEntity = new ProApplyDoubleHeavyEntity();
        proApplyDoubleHeavyEntity.setApplyDoubleHeavyState(reqUpdateApplicationForDoubleNumberVO.getApplyDoubleHeavyState());
        Date date = new Date();
        proApplyDoubleHeavyEntity.setUpdateTime(date);
        proApplyDoubleHeavyEntity.setIdProApplyDoubleHeavy(reqUpdateApplicationForDoubleNumberVO.getIdProApplyDoubleHeavy());
        proApplyDoubleHeavyDao.updateById(proApplyDoubleHeavyEntity);

        ProApplyDoubleHeavyEntity proApplyDoubleHeavyEntity1 = proApplyDoubleHeavyDao.selectById(reqUpdateApplicationForDoubleNumberVO.getIdProApplyDoubleHeavy());
        addOrUpdateProStatus(proApplyDoubleHeavyEntity1.getIdxProAdmin(),ProjectStatus.APPLICATION_FOR_DOUBLE_NUMBER.getValue(),reqUpdateApplicationForDoubleNumberVO.getSubmitState());


        if(reqUpdateApplicationForDoubleNumberVO.getSubmitState()!=null && reqUpdateApplicationForDoubleNumberVO.getSubmitState() ==3 ){
            updateStatus(proApplyDoubleHeavyEntity1.getIdxProAdmin());
        }else if( !(reqUpdateApplicationForDoubleNumberVO.getSubmitState()!=null && reqUpdateApplicationForDoubleNumberVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqUpdateApplicationForDoubleNumberVO.getSubmitState());
            proAdmin.setIdProAdmin(proApplyDoubleHeavyEntity1.getIdxProAdmin());
            proAdminDao.updateById(proAdmin);
        }

        return 1;
    }

    /**
     * 获取申请双重编号信息
     *
     * @param reqGetApplicationForDoubleNumberInfoVO
     * @return
     */
    @Override
    public ResGetApplicationForDoubleNumberInfoVO getApplicationForDoubleNumberInfo(ReqGetApplicationForDoubleNumberInfoVO reqGetApplicationForDoubleNumberInfoVO) {
        ResGetApplicationForDoubleNumberInfoVO resGetApplicationForDoubleNumberInfoVO = proApplyDoubleHeavyDao.getApplicationForDoubleNumberInfo(reqGetApplicationForDoubleNumberInfoVO);

        //获取项目状态
        ProStatusInfoAssEntity proStatusInfoAssEntity = getProStatus(resGetApplicationForDoubleNumberInfoVO.getIdxProAdmin(),
                ProjectStatus.APPLICATION_FOR_DOUBLE_NUMBER.getValue());
        resGetApplicationForDoubleNumberInfoVO.setStatus(proStatusInfoAssEntity.getStatus());
        resGetApplicationForDoubleNumberInfoVO.setSubmitState(proStatusInfoAssEntity.getSubmitState());
        return resGetApplicationForDoubleNumberInfoVO;
    }

    /**
     * 添加下达双重编号
     *
     * @param reqAddDoubleNumberingVO
     * @return
     */
    @Override
    @Transactional
    public Integer addDoubleNumbering(ReqAddDoubleNumberingVO reqAddDoubleNumberingVO) {
        ProReleaseDoubleHeavyEntity proReleaseDoubleHeavyEntity = new ProReleaseDoubleHeavyEntity();
        proReleaseDoubleHeavyEntity.setIdxProAdmin(reqAddDoubleNumberingVO.getIdProAdmin());
        proReleaseDoubleHeavyEntity.setIdxUserBaseInfo(reqAddDoubleNumberingVO.getUserId());
        proReleaseDoubleHeavyEntity.setStatus(1);
        Date date = new Date();
        proReleaseDoubleHeavyEntity.setCreateTime(date);
        proReleaseDoubleHeavyEntity.setUpdateTime(date);
        proReleaseDoubleHeavyDao.insert(proReleaseDoubleHeavyEntity);

        for (Long fileId : reqAddDoubleNumberingVO.getFileIdList()) {
            ProReleaseDoubleHeavyResourcesAssEntity proReleaseDoubleHeavyResourcesAssEntity = new ProReleaseDoubleHeavyResourcesAssEntity();
            proReleaseDoubleHeavyResourcesAssEntity.setIdxProReleaseDoubleHeavy(proReleaseDoubleHeavyEntity.getIdProReleaseDoubleHeavy());
            proReleaseDoubleHeavyResourcesAssEntity.setIdxSysFiles(fileId);
            proReleaseDoubleHeavyResourcesAssEntity.setFilesType(1);
            proReleaseDoubleHeavyResourcesAssEntity.setStatus(1);
            proReleaseDoubleHeavyResourcesAssEntity.setCreateTime(date);
            proReleaseDoubleHeavyResourcesAssEntity.setUpdateTime(date);
            proReleaseDoubleHeavyResourcesAssDao.insert(proReleaseDoubleHeavyResourcesAssEntity);
            uploadService.updateFileStatus(fileId);
        }

        addOrUpdateProStatus(reqAddDoubleNumberingVO.getIdProAdmin(),ProjectStatus.DOUBLE_NUMBERING.getValue(),reqAddDoubleNumberingVO.getSubmitState());

        if(reqAddDoubleNumberingVO.getSubmitState()!=null && reqAddDoubleNumberingVO.getSubmitState() ==3 ){
            updateStatus(reqAddDoubleNumberingVO.getIdProAdmin());
        }else if( !(reqAddDoubleNumberingVO.getSubmitState()!=null && reqAddDoubleNumberingVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqAddDoubleNumberingVO.getSubmitState());
            proAdmin.setIdProAdmin(reqAddDoubleNumberingVO.getIdProAdmin());
            proAdminDao.updateById(proAdmin);
        }
        return 1;
    }

    /**
     * 修改下达双重编号
     *
     * @param reqUpdateDoubleNumberingVO
     * @return
     */
    @Override
    @Transactional
    public Integer updateDoubleNumbering(ReqUpdateDoubleNumberingVO reqUpdateDoubleNumberingVO) {
        ProReleaseDoubleHeavyEntity proReleaseDoubleHeavyEntity = new ProReleaseDoubleHeavyEntity();
        proReleaseDoubleHeavyEntity.setIdProReleaseDoubleHeavy(reqUpdateDoubleNumberingVO.getIdProReleaseDoubleHeavy());
        proReleaseDoubleHeavyEntity.setIdxUserBaseInfo(reqUpdateDoubleNumberingVO.getUserId());
        proReleaseDoubleHeavyEntity.setStatus(1);
        Date date = new Date();
        proReleaseDoubleHeavyEntity.setUpdateTime(date);
        proReleaseDoubleHeavyDao.updateById(proReleaseDoubleHeavyEntity);

        Wrapper<ProReleaseDoubleHeavyResourcesAssEntity> wrapper = new EntityWrapper<>();
        wrapper.eq("idx_pro_release_double_heavy",reqUpdateDoubleNumberingVO.getIdProReleaseDoubleHeavy());
        proReleaseDoubleHeavyResourcesAssDao.delete(wrapper);
        for (Long fileId : reqUpdateDoubleNumberingVO.getFileIdList()) {
            ProReleaseDoubleHeavyResourcesAssEntity proReleaseDoubleHeavyResourcesAssEntity = new ProReleaseDoubleHeavyResourcesAssEntity();
            proReleaseDoubleHeavyResourcesAssEntity.setIdxProReleaseDoubleHeavy(proReleaseDoubleHeavyEntity.getIdProReleaseDoubleHeavy());
            proReleaseDoubleHeavyResourcesAssEntity.setIdxSysFiles(fileId);
            proReleaseDoubleHeavyResourcesAssEntity.setFilesType(1);
            proReleaseDoubleHeavyResourcesAssEntity.setStatus(1);
            proReleaseDoubleHeavyResourcesAssEntity.setCreateTime(date);
            proReleaseDoubleHeavyResourcesAssEntity.setUpdateTime(date);
            proReleaseDoubleHeavyResourcesAssDao.insert(proReleaseDoubleHeavyResourcesAssEntity);
            uploadService.updateFileStatus(fileId);
        }

        ProReleaseDoubleHeavyEntity proReleaseDoubleHeavyEntity1 = proReleaseDoubleHeavyDao.selectById(reqUpdateDoubleNumberingVO.getIdProReleaseDoubleHeavy());
        addOrUpdateProStatus(proReleaseDoubleHeavyEntity1.getIdxProAdmin(),ProjectStatus.DOUBLE_NUMBERING.getValue(),reqUpdateDoubleNumberingVO.getSubmitState());

        if(reqUpdateDoubleNumberingVO.getSubmitState()!=null && reqUpdateDoubleNumberingVO.getSubmitState() ==3 ){
            updateStatus(proReleaseDoubleHeavyEntity1.getIdxProAdmin());
        }else if( !(reqUpdateDoubleNumberingVO.getSubmitState()!=null && reqUpdateDoubleNumberingVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqUpdateDoubleNumberingVO.getSubmitState());
            proAdmin.setIdProAdmin(proReleaseDoubleHeavyEntity1.getIdxProAdmin());
            proAdminDao.updateById(proAdmin);
        }
        return 1;
    }

    /**
     * 获取下达双重编号信息
     *
     * @param reqGetDoubleNumberingInfoVO
     * @return
     */
    @Override
    public ResGetDoubleNumberingInfoVO getDoubleNumberingInfo(ReqGetDoubleNumberingInfoVO reqGetDoubleNumberingInfoVO) {
        ResGetDoubleNumberingInfoVO resGetDoubleNumberingInfoVO  = new ResGetDoubleNumberingInfoVO();

        ProReleaseDoubleHeavyEntity wrapper = new ProReleaseDoubleHeavyEntity();
        wrapper.setIdxProAdmin(reqGetDoubleNumberingInfoVO.getIdProAdmin());
        ProReleaseDoubleHeavyEntity proReleaseDoubleHeavyEntity = proReleaseDoubleHeavyDao.selectOne(wrapper);

        resGetDoubleNumberingInfoVO.setIdProAdmin(proReleaseDoubleHeavyEntity.getIdxProAdmin());
        resGetDoubleNumberingInfoVO.setIdxProReleaseDoubleHeavy(proReleaseDoubleHeavyEntity.getIdProReleaseDoubleHeavy());

        List<ResFileInfoVO> fileInfoVOList = proReleaseDoubleHeavyDao.getfileInfoList(proReleaseDoubleHeavyEntity.getIdProReleaseDoubleHeavy());
        resGetDoubleNumberingInfoVO.setFileIdList(fileInfoVOList);

        //获取项目状态
        ProStatusInfoAssEntity proStatusInfoAssEntity = getProStatus(resGetDoubleNumberingInfoVO.getIdProAdmin(),
                ProjectStatus.DOUBLE_NUMBERING.getValue());
        resGetDoubleNumberingInfoVO.setStatus(proStatusInfoAssEntity.getStatus());
        resGetDoubleNumberingInfoVO.setSubmitState(proStatusInfoAssEntity.getSubmitState());

        return resGetDoubleNumberingInfoVO;
    }

    /**
     * 添加告知
     *
     * @param reqAddInformVO
     * @return
     */
    @Override
    public Integer addInform(ReqAddInformVO reqAddInformVO) {
        ProInformEntity proInformEntity = new ProInformEntity();
        proInformEntity.setIdxProAdmin(reqAddInformVO.getIdProAdmin());
        proInformEntity.setBarcodeApplicationState(reqAddInformVO.getBarcodeApplicationState());
        proInformEntity.setHighChargeState(reqAddInformVO.getHighChargeState());
        proInformEntity.setCostApprovalState(reqAddInformVO.getCostApprovalState());
        proInformEntity.setThirtyFiveKvaQualityTesting(reqAddInformVO.getThirtyFiveKvaQualityTesting());
        proInformEntity.setCustomerSubmit(reqAddInformVO.getBarcodeApplicationState());
        proInformEntity.setIdxUserBaseInfo(reqAddInformVO.getUserId());
        proInformEntity.setStatus(1);
        Date date = new Date();
        proInformEntity.setCreateTime(date);
        proInformEntity.setUpdateTime(date);
        proInformDao.insert(proInformEntity);

        addOrUpdateProStatus(reqAddInformVO.getIdProAdmin(),ProjectStatus.INFORM.getValue(),reqAddInformVO.getSubmitState());

        if(reqAddInformVO.getSubmitState()!=null && reqAddInformVO.getSubmitState() ==3 ){
            updateStatus(reqAddInformVO.getIdProAdmin());
        }else if( !(reqAddInformVO.getSubmitState()!=null && reqAddInformVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqAddInformVO.getSubmitState());
            proAdmin.setIdProAdmin(reqAddInformVO.getIdProAdmin());
            proAdminDao.updateById(proAdmin);
        }
        return 1;
    }

    /**
     * 修改告知
     *
     * @param reqUpdateInformVO
     * @return
     */
    @Override
    public Integer updateInform(ReqUpdateInformVO reqUpdateInformVO) {
        ProInformEntity proInformEntity = new ProInformEntity();
        proInformEntity.setIdProInform(reqUpdateInformVO.getIdProInform());
        proInformEntity.setBarcodeApplicationState(reqUpdateInformVO.getBarcodeApplicationState());
        proInformEntity.setHighChargeState(reqUpdateInformVO.getHighChargeState());
        proInformEntity.setCostApprovalState(reqUpdateInformVO.getCostApprovalState());
        proInformEntity.setThirtyFiveKvaQualityTesting(reqUpdateInformVO.getThirtyFiveKvaQualityTesting());
        proInformEntity.setCustomerSubmit(reqUpdateInformVO.getBarcodeApplicationState());
        proInformEntity.setIdxUserBaseInfo(reqUpdateInformVO.getUserId());
        Date date = new Date();
        proInformEntity.setCreateTime(date);
        proInformEntity.setUpdateTime(date);
        proInformDao.updateById(proInformEntity);

        ProInformEntity proInformEntity1 = proInformDao.selectById(reqUpdateInformVO.getIdProInform());
        addOrUpdateProStatus(proInformEntity1.getIdxProAdmin(),ProjectStatus.INFORM.getValue(),reqUpdateInformVO.getSubmitState());


        if(reqUpdateInformVO.getSubmitState()!=null && reqUpdateInformVO.getSubmitState() ==3 ){
            updateStatus(proInformEntity1.getIdxProAdmin());
        }else if( !(reqUpdateInformVO.getSubmitState()!=null && reqUpdateInformVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqUpdateInformVO.getSubmitState());
            proAdmin.setIdProAdmin(proInformEntity1.getIdxProAdmin());
            proAdminDao.updateById(proAdmin);
        }
        return 1;
    }

    /**
     * 获取告知
     *
     * @param reqGetInformVO
     * @return
     */
    @Override
    public ResGetInformVO getInform(ReqGetInformVO reqGetInformVO) {
        ResGetInformVO resGetInformVO = proInformDao.getInform(reqGetInformVO);
        /*ProAdminEntity proAdminEntity = proAdminDao.selectById(resGetInformVO.getIdProAdmin());
        resGetInformVO.setSubmitState(proAdminEntity.getSubmitState());
        resGetInformVO.setStatus(proAdminEntity.getStatus().getValue());*/

        //获取项目状态
        ProStatusInfoAssEntity proStatusInfoAssEntity = getProStatus(reqGetInformVO.getIdProAdmin(),
                ProjectStatus.INFORM.getValue());
        resGetInformVO.setStatus(proStatusInfoAssEntity.getStatus());
        resGetInformVO.setSubmitState(proStatusInfoAssEntity.getSubmitState());
        return resGetInformVO;
    }

    /**
     * 添加停电接火
     *
     * @param reqAddBlackoutAndFireVO
     * @return
     */
    @Override
    @Transactional
    public Integer addBlackoutAndFire(ReqAddBlackoutAndFireVO reqAddBlackoutAndFireVO) {
        ProBlackoutFiringEntity proBlackoutFiringEntity = new ProBlackoutFiringEntity();
        proBlackoutFiringEntity.setIdxProAdmin(reqAddBlackoutAndFireVO.getIdxProAdmin());
        proBlackoutFiringEntity.setApplicationForm(reqAddBlackoutAndFireVO.getApplicationForm());
        proBlackoutFiringEntity.setExaminationSummary(reqAddBlackoutAndFireVO.getExaminationSummary());
        proBlackoutFiringEntity.setExaminationSummaryAutograph(reqAddBlackoutAndFireVO.getExaminationSummaryAutograph());
        proBlackoutFiringEntity.setConstructionPlan(reqAddBlackoutAndFireVO.getConstructionPlan());
        proBlackoutFiringEntity.setIdxUserBaseInfo(reqAddBlackoutAndFireVO.getUserId());
        proBlackoutFiringEntity.setStatus(1);
        Date date = new Date();
        proBlackoutFiringEntity.setCreateTime(date);
        proBlackoutFiringEntity.setUpdateTime(date);
        proBlackoutFiringDao.insert(proBlackoutFiringEntity);

        addOrUpdateProStatus(reqAddBlackoutAndFireVO.getIdxProAdmin(),ProjectStatus.BLACKOUT_AND_FIRE.getValue(),reqAddBlackoutAndFireVO.getSubmitState());
        if(reqAddBlackoutAndFireVO.getSubmitState()!=null && reqAddBlackoutAndFireVO.getSubmitState() ==3 ){
            updateStatus(reqAddBlackoutAndFireVO.getIdxProAdmin());
        }else if( !(reqAddBlackoutAndFireVO.getSubmitState()!=null && reqAddBlackoutAndFireVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqAddBlackoutAndFireVO.getSubmitState());
            proAdmin.setIdProAdmin(reqAddBlackoutAndFireVO.getIdxProAdmin());
            proAdminDao.updateById(proAdmin);
        }
        uploadService.updateFileStatus(reqAddBlackoutAndFireVO.getApplicationForm());
        uploadService.updateFileStatus(reqAddBlackoutAndFireVO.getExaminationSummary());
        uploadService.updateFileStatus(reqAddBlackoutAndFireVO.getExaminationSummaryAutograph());
        uploadService.updateFileStatus(reqAddBlackoutAndFireVO.getConstructionPlan());
        return 1;
    }

    /**
     * 修改停电接火
     *
     * @param reqUpdateBlackoutAndFireVO
     * @return
     */
    @Override
    @Transactional
    public Integer updateBlackoutAndFire(ReqUpdateBlackoutAndFireVO reqUpdateBlackoutAndFireVO) {
        ProBlackoutFiringEntity proBlackoutFiringEntity = new ProBlackoutFiringEntity();
        proBlackoutFiringEntity.setApplicationForm(reqUpdateBlackoutAndFireVO.getApplicationForm());
        proBlackoutFiringEntity.setExaminationSummary(reqUpdateBlackoutAndFireVO.getExaminationSummary());
        proBlackoutFiringEntity.setExaminationSummaryAutograph(reqUpdateBlackoutAndFireVO.getExaminationSummaryAutograph());
        proBlackoutFiringEntity.setConstructionPlan(reqUpdateBlackoutAndFireVO.getConstructionPlan());
        proBlackoutFiringEntity.setIdxUserBaseInfo(reqUpdateBlackoutAndFireVO.getUserId());
        proBlackoutFiringEntity.setIdProBlackoutFiring(reqUpdateBlackoutAndFireVO.getIdProBlackoutFiring());
        proBlackoutFiringEntity.setStatus(1);
        Date date = new Date();
        proBlackoutFiringEntity.setCreateTime(date);
        proBlackoutFiringEntity.setUpdateTime(date);
        proBlackoutFiringDao.insert(proBlackoutFiringEntity);

        ProBlackoutFiringEntity proBlackoutFiringEntity1 = proBlackoutFiringDao.selectById(reqUpdateBlackoutAndFireVO.getIdProBlackoutFiring());
        addOrUpdateProStatus(proBlackoutFiringEntity1.getIdxProAdmin(),ProjectStatus.BLACKOUT_AND_FIRE.getValue(),reqUpdateBlackoutAndFireVO.getSubmitState());

        if(reqUpdateBlackoutAndFireVO.getSubmitState()!=null && reqUpdateBlackoutAndFireVO.getSubmitState() ==3 ){
            updateStatus(proBlackoutFiringEntity1.getIdxProAdmin());
        }else if( !(reqUpdateBlackoutAndFireVO.getSubmitState()!=null && reqUpdateBlackoutAndFireVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqUpdateBlackoutAndFireVO.getSubmitState());
            proAdmin.setIdProAdmin(proBlackoutFiringEntity1.getIdxProAdmin());
            proAdminDao.updateById(proAdmin);
        }
        uploadService.updateFileStatus(reqUpdateBlackoutAndFireVO.getApplicationForm());
        uploadService.updateFileStatus(reqUpdateBlackoutAndFireVO.getExaminationSummary());
        uploadService.updateFileStatus(reqUpdateBlackoutAndFireVO.getExaminationSummaryAutograph());
        uploadService.updateFileStatus(reqUpdateBlackoutAndFireVO.getConstructionPlan());
        return 1;
    }

    /**
     * 获取停电接火信息
     *
     * @param reqGetBlackoutAndFireInfoVO
     * @return
     */
    @Override
    public ResGetBlackoutAndFireInfoVO getBlackoutAndFireInfo(ReqGetBlackoutAndFireInfoVO reqGetBlackoutAndFireInfoVO) {
        ResGetBlackoutAndFireInfoVO resGetBlackoutAndFireInfoVO = new ResGetBlackoutAndFireInfoVO();


        ProBlackoutFiringEntity wrapper = new ProBlackoutFiringEntity();
        wrapper.setIdxProAdmin(reqGetBlackoutAndFireInfoVO.getIdProAdmin());
        ProBlackoutFiringEntity proBlackoutFiringEntity = proBlackoutFiringDao.selectOne(wrapper);
        resGetBlackoutAndFireInfoVO.setIdProBlackoutFiring(proBlackoutFiringEntity.getIdProBlackoutFiring());
        resGetBlackoutAndFireInfoVO.setIdProAdmin(proBlackoutFiringEntity.getIdxProAdmin());

        resGetBlackoutAndFireInfoVO.setApplicationForm(proBlackoutFiringEntity.getApplicationForm());
        SysFilesEntity sysFilesEntityApplicationForm = sysFilesDao.selectById(proBlackoutFiringEntity.getApplicationForm());
        resGetBlackoutAndFireInfoVO.setApplicationFormFileName(sysFilesEntityApplicationForm.getFileName());
        resGetBlackoutAndFireInfoVO.setApplicationFormFilePath(sysFilesEntityApplicationForm.getFilePath());
        resGetBlackoutAndFireInfoVO.setApplicationFormSuffixName(sysFilesEntityApplicationForm.getSuffixName());

        resGetBlackoutAndFireInfoVO.setConstructionPlan(proBlackoutFiringEntity.getConstructionPlan());
        SysFilesEntity sysFilesEntityConstructionPlan = sysFilesDao.selectById(proBlackoutFiringEntity.getConstructionPlan());
        resGetBlackoutAndFireInfoVO.setConstructionPlanFileName(sysFilesEntityConstructionPlan.getFileName());
        resGetBlackoutAndFireInfoVO.setConstructionPlanFilePath(sysFilesEntityConstructionPlan.getFilePath());
        resGetBlackoutAndFireInfoVO.setConstructionPlanSuffixName(sysFilesEntityConstructionPlan.getSuffixName());
        
        resGetBlackoutAndFireInfoVO.setExaminationSummary(proBlackoutFiringEntity.getExaminationSummary());
        SysFilesEntity sysFilesEntityExaminationSummary = sysFilesDao.selectById(proBlackoutFiringEntity.getExaminationSummary());
        resGetBlackoutAndFireInfoVO.setExaminationSummaryFileName(sysFilesEntityExaminationSummary.getFileName());
        resGetBlackoutAndFireInfoVO.setExaminationSummaryFilePath(sysFilesEntityExaminationSummary.getFilePath());
        resGetBlackoutAndFireInfoVO.setExaminationSummarySuffixName(sysFilesEntityExaminationSummary.getSuffixName());
        
        resGetBlackoutAndFireInfoVO.setExaminationSummaryAutograph(proBlackoutFiringEntity.getExaminationSummaryAutograph());
        SysFilesEntity sysFilesEntityExaminationSummaryAutograph = sysFilesDao.selectById(proBlackoutFiringEntity.getExaminationSummaryAutograph());
        resGetBlackoutAndFireInfoVO.setExaminationSummaryAutographFileName(sysFilesEntityExaminationSummaryAutograph.getFileName());
        resGetBlackoutAndFireInfoVO.setExaminationSummaryAutographFilePath(sysFilesEntityExaminationSummaryAutograph.getFilePath());
        resGetBlackoutAndFireInfoVO.setExaminationSummaryAutographSuffixName(sysFilesEntityExaminationSummaryAutograph.getSuffixName());

        //获取项目状态
        ProStatusInfoAssEntity proStatusInfoAssEntity = getProStatus(reqGetBlackoutAndFireInfoVO.getIdProAdmin(),
                ProjectStatus.BLACKOUT_AND_FIRE.getValue());
        resGetBlackoutAndFireInfoVO.setStatus(proStatusInfoAssEntity.getStatus());
        resGetBlackoutAndFireInfoVO.setSubmitState(proStatusInfoAssEntity.getSubmitState());

        return resGetBlackoutAndFireInfoVO;
    }

    /**
     * 添加检查验收
     *
     * @param reqAddIntermediateInspectionVO
     * @return
     */
    @Override
    @Transactional
    public Integer addIntermediateInspection(ReqAddIntermediateInspectionVO reqAddIntermediateInspectionVO) {
        ProReExaminationEntity proReExaminationEntity = new ProReExaminationEntity();
        proReExaminationEntity.setIdxProAdmin(reqAddIntermediateInspectionVO.getIdProAdmin());
        Wrapper<ProReExaminationEntity> wrapper = new EntityWrapper<>();
        wrapper.eq("idx_pro_admin",reqAddIntermediateInspectionVO.getIdProAdmin());
        wrapper.eq("test_type",reqAddIntermediateInspectionVO.getTestType());
        Integer count = proReExaminationDao.selectCount(wrapper);
        proReExaminationEntity.setReExaminationFrequency(count+1);
        proReExaminationEntity.setTestType(reqAddIntermediateInspectionVO.getTestType());
        proReExaminationEntity.setConstructionUnit(reqAddIntermediateInspectionVO.getConstructionUnit());
        proReExaminationEntity.setReExaminationType(reqAddIntermediateInspectionVO.getReExaminationType());
        proReExaminationEntity.setCheckAcceptanceProName(reqAddIntermediateInspectionVO.getCheckAcceptanceProName());
        proReExaminationEntity.setExistingProblems(reqAddIntermediateInspectionVO.getExistingProblems());
        proReExaminationEntity.setDesignChartDiscrepancy(reqAddIntermediateInspectionVO.getDesignChartDiscrepancy());
        proReExaminationEntity.setAmendments(reqAddIntermediateInspectionVO.getAmendments());
        proReExaminationEntity.setOrganizationalUnit(reqAddIntermediateInspectionVO.getOrganizationalUnit());
        proReExaminationEntity.setOrganizationalUnitCharge(reqAddIntermediateInspectionVO.getOrganizationalUnitCharge());
        proReExaminationEntity.setConstructionPersonCharge(reqAddIntermediateInspectionVO.getConstructionPersonCharge());
        proReExaminationEntity.setAcceptanceUnit(reqAddIntermediateInspectionVO.getAcceptanceUnit());
        proReExaminationEntity.setAcceptanceUnitCharge(reqAddIntermediateInspectionVO.getAcceptanceUnitCharge());
        proReExaminationEntity.setCustomerPersonCharge(reqAddIntermediateInspectionVO.getCustomerPersonCharge());

        proReExaminationEntity.setPersonCharge1(reqAddIntermediateInspectionVO.getPersonCharge1());
        proReExaminationEntity.setPersonCharge2(reqAddIntermediateInspectionVO.getPersonCharge2());

        Date date = new Date();

        proReExaminationEntity.setProgressProjectDescribe(reqAddIntermediateInspectionVO.getProgressProjectDescribe());
        proReExaminationEntity.setIdxUserBaseInfo(reqAddIntermediateInspectionVO.getUserId());
        proReExaminationEntity.setStatus(1);
        proReExaminationEntity.setCreateTime(date);
        proReExaminationEntity.setUpdateTime(date);
        proReExaminationDao.insert(proReExaminationEntity);

        //现场照片资源列表
        if(ParametersUtil.isNotNull(reqAddIntermediateInspectionVO.getLivePhotosList())){
            for (ReqResourcesVO reqExaminationResourcesVO : reqAddIntermediateInspectionVO.getLivePhotosList()) {

                ProReExaminationResourcesAssEntity proReExaminationResourcesAssEntity = new ProReExaminationResourcesAssEntity();
                proReExaminationResourcesAssEntity.setIdxProReExamination(proReExaminationEntity.getIdProReExamination());
                proReExaminationResourcesAssEntity.setIdxSysFiles(reqExaminationResourcesVO.getIdSysFiles());
                proReExaminationResourcesAssEntity.setFilesType(1);
                proReExaminationResourcesAssEntity.setResourcesType(reqExaminationResourcesVO.getResourcesType());
                proReExaminationResourcesAssEntity.setStatus(1);
                proReExaminationResourcesAssEntity.setCreateTime(date);
                proReExaminationResourcesAssEntity.setUpdateTime(date);
                proReExaminationResourcesAssDao.insert(proReExaminationResourcesAssEntity);
                uploadService.updateFileStatus(reqExaminationResourcesVO.getIdSysFiles());
            }
        }

        //整改报告资源列表
        if(ParametersUtil.isNotNull(reqAddIntermediateInspectionVO.getRectificationReportList())){
            for (ReqResourcesVO reqExaminationResourcesVO : reqAddIntermediateInspectionVO.getRectificationReportList()) {

                ProReExaminationResourcesAssEntity proReExaminationResourcesAssEntity = new ProReExaminationResourcesAssEntity();
                proReExaminationResourcesAssEntity.setIdxProReExamination(proReExaminationEntity.getIdProReExamination());
                proReExaminationResourcesAssEntity.setIdxSysFiles(reqExaminationResourcesVO.getIdSysFiles());
                proReExaminationResourcesAssEntity.setFilesType(1);
                proReExaminationResourcesAssEntity.setResourcesType(reqExaminationResourcesVO.getResourcesType());
                proReExaminationResourcesAssEntity.setStatus(1);
                proReExaminationResourcesAssEntity.setCreateTime(date);
                proReExaminationResourcesAssEntity.setUpdateTime(date);
                proReExaminationResourcesAssDao.insert(proReExaminationResourcesAssEntity);
                uploadService.updateFileStatus(reqExaminationResourcesVO.getIdSysFiles());
            }
        }

        //添加三个类型的不同项目状态
        if(ParametersUtil.isNotNull(reqAddIntermediateInspectionVO.getTestType()) && reqAddIntermediateInspectionVO.getTestType() == 3){
            addOrUpdateProStatus(reqAddIntermediateInspectionVO.getIdProAdmin(),ProjectStatus.INTERMEDIATE_INSPECTION.getValue(),reqAddIntermediateInspectionVO.getSubmitState());
        }else if(ParametersUtil.isNotNull(reqAddIntermediateInspectionVO.getTestType()) && reqAddIntermediateInspectionVO.getTestType() == 2){
            addOrUpdateProStatus(reqAddIntermediateInspectionVO.getIdProAdmin(),ProjectStatus.COMPLETION_ACCEPTANCE.getValue(),reqAddIntermediateInspectionVO.getSubmitState());
        }else if(ParametersUtil.isNotNull(reqAddIntermediateInspectionVO.getTestType()) && reqAddIntermediateInspectionVO.getTestType() == 1){
            addOrUpdateProStatus(reqAddIntermediateInspectionVO.getIdProAdmin(),ProjectStatus.REEXAMINATION.getValue(),reqAddIntermediateInspectionVO.getSubmitState());
        }
        if(reqAddIntermediateInspectionVO.getSubmitState()!=null && reqAddIntermediateInspectionVO.getSubmitState() ==3 ){
            updateStatus(reqAddIntermediateInspectionVO.getIdProAdmin());
        }else if( !(reqAddIntermediateInspectionVO.getSubmitState()!=null && reqAddIntermediateInspectionVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqAddIntermediateInspectionVO.getSubmitState());
            proAdmin.setIdProAdmin(reqAddIntermediateInspectionVO.getIdProAdmin());
            proAdminDao.updateById(proAdmin);
        }

        return 1;
    }

    /**
     * 修改检查验收
     *
     * @param reqUpdateIntermediateInspectionVO
     * @return
     */
    @Override
    @Transactional
    public Integer updateIntermediateInspection(ReqUpdateIntermediateInspectionVO reqUpdateIntermediateInspectionVO) {
        ProReExaminationEntity proReExaminationEntity = new ProReExaminationEntity();
        proReExaminationEntity.setTestType(reqUpdateIntermediateInspectionVO.getTestType());
        proReExaminationEntity.setConstructionUnit(reqUpdateIntermediateInspectionVO.getConstructionUnit());
        proReExaminationEntity.setReExaminationType(reqUpdateIntermediateInspectionVO.getReExaminationType());
        proReExaminationEntity.setCheckAcceptanceProName(reqUpdateIntermediateInspectionVO.getCheckAcceptanceProName());
        proReExaminationEntity.setExistingProblems(reqUpdateIntermediateInspectionVO.getExistingProblems());
        proReExaminationEntity.setDesignChartDiscrepancy(reqUpdateIntermediateInspectionVO.getDesignChartDiscrepancy());
        proReExaminationEntity.setAmendments(reqUpdateIntermediateInspectionVO.getAmendments());
        proReExaminationEntity.setOrganizationalUnit(reqUpdateIntermediateInspectionVO.getOrganizationalUnit());
        proReExaminationEntity.setOrganizationalUnitCharge(reqUpdateIntermediateInspectionVO.getOrganizationalUnitCharge());
        proReExaminationEntity.setConstructionPersonCharge(reqUpdateIntermediateInspectionVO.getConstructionPersonCharge());
        proReExaminationEntity.setAcceptanceUnit(reqUpdateIntermediateInspectionVO.getAcceptanceUnit());
        proReExaminationEntity.setAcceptanceUnitCharge(reqUpdateIntermediateInspectionVO.getAcceptanceUnitCharge());
        proReExaminationEntity.setCustomerPersonCharge(reqUpdateIntermediateInspectionVO.getCustomerPersonCharge());
        proReExaminationEntity.setPersonCharge1(reqUpdateIntermediateInspectionVO.getPersonCharge1());
        proReExaminationEntity.setPersonCharge2(reqUpdateIntermediateInspectionVO.getPersonCharge2());
        proReExaminationEntity.setProgressProjectDescribe(reqUpdateIntermediateInspectionVO.getProgressProjectDescribe());
        proReExaminationEntity.setIdxUserBaseInfo(reqUpdateIntermediateInspectionVO.getUserId());
        proReExaminationEntity.setStatus(1);
        Date date = new Date();
        proReExaminationEntity.setCreateTime(date);
        proReExaminationEntity.setUpdateTime(date);
        proReExaminationEntity.setIdProReExamination(reqUpdateIntermediateInspectionVO.getIdProReExamination());
        proReExaminationDao.updateById(proReExaminationEntity);

        Wrapper<ProReExaminationResourcesAssEntity> wrapper = new EntityWrapper<>();
        wrapper.eq("idx_pro_re_examination",reqUpdateIntermediateInspectionVO.getIdProReExamination());
        proReExaminationResourcesAssDao.delete(wrapper);
        if(ParametersUtil.isNotNull(reqUpdateIntermediateInspectionVO.getLivePhotosList())) {
            for (ReqResourcesVO reqExaminationResourcesVO : reqUpdateIntermediateInspectionVO.getLivePhotosList()) {
                ProReExaminationResourcesAssEntity proReExaminationResourcesAssEntity = new ProReExaminationResourcesAssEntity();
                proReExaminationResourcesAssEntity.setIdxProReExamination(proReExaminationEntity.getIdProReExamination());
                proReExaminationResourcesAssEntity.setIdxSysFiles(reqExaminationResourcesVO.getIdSysFiles());
                proReExaminationResourcesAssEntity.setFilesType(1);
                proReExaminationResourcesAssEntity.setResourcesType(reqExaminationResourcesVO.getResourcesType());
                proReExaminationResourcesAssEntity.setStatus(1);
                proReExaminationResourcesAssEntity.setCreateTime(date);
                proReExaminationResourcesAssEntity.setUpdateTime(date);
                proReExaminationResourcesAssDao.insert(proReExaminationResourcesAssEntity);
                uploadService.updateFileStatus(reqExaminationResourcesVO.getIdSysFiles());
            }
        }

        if(ParametersUtil.isNotNull(reqUpdateIntermediateInspectionVO.getRectificationReportList())) {
            for (ReqResourcesVO reqExaminationResourcesVO : reqUpdateIntermediateInspectionVO.getRectificationReportList()) {
                ProReExaminationResourcesAssEntity proReExaminationResourcesAssEntity = new ProReExaminationResourcesAssEntity();
                proReExaminationResourcesAssEntity.setIdxProReExamination(proReExaminationEntity.getIdProReExamination());
                proReExaminationResourcesAssEntity.setIdxSysFiles(reqExaminationResourcesVO.getIdSysFiles());
                proReExaminationResourcesAssEntity.setFilesType(1);
                proReExaminationResourcesAssEntity.setResourcesType(reqExaminationResourcesVO.getResourcesType());
                proReExaminationResourcesAssEntity.setStatus(1);
                proReExaminationResourcesAssEntity.setCreateTime(date);
                proReExaminationResourcesAssEntity.setUpdateTime(date);
                proReExaminationResourcesAssDao.insert(proReExaminationResourcesAssEntity);
                uploadService.updateFileStatus(reqExaminationResourcesVO.getIdSysFiles());
            }
        }

        ProReExaminationEntity proReExaminationEntity1 = proReExaminationDao.selectById(reqUpdateIntermediateInspectionVO.getIdProReExamination());
        //添加三个类型的不同项目状态
        if(ParametersUtil.isNotNull(reqUpdateIntermediateInspectionVO.getTestType()) && reqUpdateIntermediateInspectionVO.getTestType() == 3){
            addOrUpdateProStatus(reqUpdateIntermediateInspectionVO.getIdProAdmin(),ProjectStatus.INTERMEDIATE_INSPECTION.getValue(),reqUpdateIntermediateInspectionVO.getSubmitState());
        }else if(ParametersUtil.isNotNull(reqUpdateIntermediateInspectionVO.getTestType()) && reqUpdateIntermediateInspectionVO.getTestType() == 2){
            addOrUpdateProStatus(reqUpdateIntermediateInspectionVO.getIdProAdmin(),ProjectStatus.COMPLETION_ACCEPTANCE.getValue(),reqUpdateIntermediateInspectionVO.getSubmitState());
        }else if(ParametersUtil.isNotNull(reqUpdateIntermediateInspectionVO.getTestType()) && reqUpdateIntermediateInspectionVO.getTestType() == 1){
            addOrUpdateProStatus(reqUpdateIntermediateInspectionVO.getIdProAdmin(),ProjectStatus.REEXAMINATION.getValue(),reqUpdateIntermediateInspectionVO.getSubmitState());
        }


        if(reqUpdateIntermediateInspectionVO.getSubmitState()!=null && reqUpdateIntermediateInspectionVO.getSubmitState() ==3 ){
            updateStatus(proReExaminationEntity1.getIdxProAdmin());
        }else if( !(reqUpdateIntermediateInspectionVO.getSubmitState()!=null && reqUpdateIntermediateInspectionVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqUpdateIntermediateInspectionVO.getSubmitState());
            proAdmin.setIdProAdmin(proReExaminationEntity1.getIdxProAdmin());
            proAdminDao.updateById(proAdmin);
        }

        return 1;
    }

    /**
     * 获取检查验收
     *
     * @param reqGetIntermediateInspectionVO
     * @return
     */
    @Override
    public ResGetIntermediateInspectionVO getIntermediateInspectionInfo(ReqGetIntermediateInspectionVO reqGetIntermediateInspectionVO) {
        ResGetIntermediateInspectionVO resGetIntermediateInspectionVO = proReExaminationDao.getIntermediateInspectionInfo(reqGetIntermediateInspectionVO);
        resGetIntermediateInspectionVO.setScenePicturesList(proReExaminationDao.getExaminationResourcesList(reqGetIntermediateInspectionVO,1));
        resGetIntermediateInspectionVO.setRectificationUnitSubmitsRectificationReportList(proReExaminationDao.getExaminationResourcesList(reqGetIntermediateInspectionVO,2));

        ProStatusInfoAssEntity proStatusInfoAssEntity = getProStatus(resGetIntermediateInspectionVO.getIdProAdmin(),
                reqGetIntermediateInspectionVO.getStatus().getValue());
        resGetIntermediateInspectionVO.setStatus(proStatusInfoAssEntity.getStatus());
        resGetIntermediateInspectionVO.setSubmitState(proStatusInfoAssEntity.getSubmitState());

        return resGetIntermediateInspectionVO;
    }

    /**
     * 添加送电启动
     * @param reqAddPowerTransmissionStartUpVO
     * @return
     */
    @Override
    @Transactional
    public Integer addPowerTransmissionStartUp(ReqAddPowerTransmissionStartUpVO reqAddPowerTransmissionStartUpVO) {
        ProTransmissionStartupEntity proTransmissionStartupEntity = new ProTransmissionStartupEntity();
        proTransmissionStartupEntity.setIdxProAdmin(reqAddPowerTransmissionStartUpVO.getIdProAdmin());
        proTransmissionStartupEntity.setIdxUserBaseInfo(reqAddPowerTransmissionStartUpVO.getUserId());
        proTransmissionStartupEntity.setStatus(1);
        Date date = new Date();
        proTransmissionStartupEntity.setCreateTime(date);
        proTransmissionStartupEntity.setUpdateTime(date);
        proTransmissionStartupDao.insert(proTransmissionStartupEntity);

        if(ParametersUtil.isNotNull(reqAddPowerTransmissionStartUpVO.getIdxSysFilesListFile())) {
            for (ReqResourcesVO reqResourcesVO : reqAddPowerTransmissionStartUpVO.getIdxSysFilesListFile()) {
                ProTransmissionStartupResourcesAssEntity proTransmissionStartupResourcesAssEntity = new ProTransmissionStartupResourcesAssEntity();
                proTransmissionStartupResourcesAssEntity.setIdxProTransmission(proTransmissionStartupEntity.getIdProTransmission());
                proTransmissionStartupResourcesAssEntity.setIdxSysFiles(reqResourcesVO.getIdSysFiles());
                proTransmissionStartupResourcesAssEntity.setFilesType(1);
                proTransmissionStartupResourcesAssEntity.setResourcesType(1);
                proTransmissionStartupResourcesAssEntity.setStatus(1);
                proTransmissionStartupResourcesAssEntity.setCreateTime(date);
                proTransmissionStartupResourcesAssEntity.setUpdateTime(date);
                proTransmissionStartupResourcesAssDao.insert(proTransmissionStartupResourcesAssEntity);
                uploadService.updateFileStatus(reqResourcesVO.getIdSysFiles());
            }
        }
        if(ParametersUtil.isNotNull(reqAddPowerTransmissionStartUpVO.getCommissioningApprovalListFile())) {
            for (ReqResourcesVO reqResourcesVO : reqAddPowerTransmissionStartUpVO.getCommissioningApprovalListFile()) {
                ProTransmissionStartupResourcesAssEntity proTransmissionStartupResourcesAssEntity = new ProTransmissionStartupResourcesAssEntity();
                proTransmissionStartupResourcesAssEntity.setIdxProTransmission(proTransmissionStartupEntity.getIdProTransmission());
                proTransmissionStartupResourcesAssEntity.setIdxSysFiles(reqResourcesVO.getIdSysFiles());
                proTransmissionStartupResourcesAssEntity.setFilesType(1);
                proTransmissionStartupResourcesAssEntity.setResourcesType(2);
                proTransmissionStartupResourcesAssEntity.setStatus(1);
                proTransmissionStartupResourcesAssEntity.setCreateTime(date);
                proTransmissionStartupResourcesAssEntity.setUpdateTime(date);
                proTransmissionStartupResourcesAssDao.insert(proTransmissionStartupResourcesAssEntity);
                uploadService.updateFileStatus(reqResourcesVO.getIdSysFiles());
            }
        }

        if(ParametersUtil.isNotNull(reqAddPowerTransmissionStartUpVO.getAccessNetworkApprovalListFile())) {
            for (ReqResourcesVO reqResourcesVO : reqAddPowerTransmissionStartUpVO.getAccessNetworkApprovalListFile()) {
                ProTransmissionStartupResourcesAssEntity proTransmissionStartupResourcesAssEntity = new ProTransmissionStartupResourcesAssEntity();
                proTransmissionStartupResourcesAssEntity.setIdxProTransmission(proTransmissionStartupEntity.getIdProTransmission());
                proTransmissionStartupResourcesAssEntity.setIdxSysFiles(reqResourcesVO.getIdSysFiles());
                proTransmissionStartupResourcesAssEntity.setFilesType(1);
                proTransmissionStartupResourcesAssEntity.setResourcesType(3);
                proTransmissionStartupResourcesAssEntity.setStatus(1);
                proTransmissionStartupResourcesAssEntity.setCreateTime(date);
                proTransmissionStartupResourcesAssEntity.setUpdateTime(date);
                proTransmissionStartupResourcesAssDao.insert(proTransmissionStartupResourcesAssEntity);
                uploadService.updateFileStatus(reqResourcesVO.getIdSysFiles());
            }
        }


        addOrUpdateProStatus(reqAddPowerTransmissionStartUpVO.getIdProAdmin(),ProjectStatus.POWER_TRANSMISSION_START_UP.getValue(),reqAddPowerTransmissionStartUpVO.getSubmitState());


        if(reqAddPowerTransmissionStartUpVO.getSubmitState()!=null && reqAddPowerTransmissionStartUpVO.getSubmitState() ==3 ){
            updateStatus(reqAddPowerTransmissionStartUpVO.getIdProAdmin());
            //修改项目送电启动状态
            updateTransmissionStatus(reqAddPowerTransmissionStartUpVO.getIdProAdmin());
        }else if( !(reqAddPowerTransmissionStartUpVO.getSubmitState()!=null && reqAddPowerTransmissionStartUpVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqAddPowerTransmissionStartUpVO.getSubmitState());
            proAdmin.setIdProAdmin(reqAddPowerTransmissionStartUpVO.getIdProAdmin());
            proAdminDao.updateById(proAdmin);
        }
        return 1;
    }

    /**
     * 修改送电启动
     *
     * @param reqUpdatePowerTransmissionStartUpVO
     * @return
     */
    @Override
    public Integer updatePowerTransmissionStartUp(ReqUpdatePowerTransmissionStartUpVO reqUpdatePowerTransmissionStartUpVO) {
        ProTransmissionStartupEntity proTransmissionStartupEntity = new ProTransmissionStartupEntity();
        proTransmissionStartupEntity.setIdxUserBaseInfo(reqUpdatePowerTransmissionStartUpVO.getUserId());
        proTransmissionStartupEntity.setStatus(1);
        Date date = new Date();
        proTransmissionStartupEntity.setCreateTime(date);
        proTransmissionStartupEntity.setUpdateTime(date);
        proTransmissionStartupEntity.setIdProTransmission(reqUpdatePowerTransmissionStartUpVO.getIdProTransmission());
        proTransmissionStartupDao.updateById(proTransmissionStartupEntity);

        Wrapper<ProTransmissionStartupResourcesAssEntity> wrapper = new EntityWrapper<>();
        wrapper.eq("idx_pro_transmission",reqUpdatePowerTransmissionStartUpVO.getIdProTransmission());
        wrapper.eq("resources_type",1);
        if(ParametersUtil.isNotNull(reqUpdatePowerTransmissionStartUpVO.getIdxSysFilesListFile())) {
            proTransmissionStartupResourcesAssDao.delete(wrapper);
            for (ReqResourcesVO reqResourcesVO : reqUpdatePowerTransmissionStartUpVO.getIdxSysFilesListFile()) {
                ProTransmissionStartupResourcesAssEntity proTransmissionStartupResourcesAssEntity = new ProTransmissionStartupResourcesAssEntity();
                proTransmissionStartupResourcesAssEntity.setIdxProTransmission(proTransmissionStartupEntity.getIdProTransmission());
                proTransmissionStartupResourcesAssEntity.setIdxSysFiles(reqResourcesVO.getIdSysFiles());
                proTransmissionStartupResourcesAssEntity.setFilesType(1);
                proTransmissionStartupResourcesAssEntity.setResourcesType(1);
                proTransmissionStartupResourcesAssEntity.setStatus(1);
                proTransmissionStartupResourcesAssEntity.setCreateTime(date);
                proTransmissionStartupResourcesAssEntity.setUpdateTime(date);
                proTransmissionStartupResourcesAssDao.insert(proTransmissionStartupResourcesAssEntity);
                uploadService.updateFileStatus(reqResourcesVO.getIdSysFiles());
            }
        }
        wrapper = new EntityWrapper<>();
        wrapper.eq("idx_pro_transmission",reqUpdatePowerTransmissionStartUpVO.getIdProTransmission());
        wrapper.eq("resources_type",2);
        if(ParametersUtil.isNotNull(reqUpdatePowerTransmissionStartUpVO.getCommissioningApprovalListFile())) {
            proTransmissionStartupResourcesAssDao.delete(wrapper);
            for (ReqResourcesVO reqResourcesVO : reqUpdatePowerTransmissionStartUpVO.getCommissioningApprovalListFile()) {
                ProTransmissionStartupResourcesAssEntity proTransmissionStartupResourcesAssEntity = new ProTransmissionStartupResourcesAssEntity();
                proTransmissionStartupResourcesAssEntity.setIdxProTransmission(proTransmissionStartupEntity.getIdProTransmission());
                proTransmissionStartupResourcesAssEntity.setIdxSysFiles(reqResourcesVO.getIdSysFiles());
                proTransmissionStartupResourcesAssEntity.setFilesType(1);
                proTransmissionStartupResourcesAssEntity.setResourcesType(2);
                proTransmissionStartupResourcesAssEntity.setStatus(1);
                proTransmissionStartupResourcesAssEntity.setCreateTime(date);
                proTransmissionStartupResourcesAssEntity.setUpdateTime(date);
                proTransmissionStartupResourcesAssEntity.setResourcesType(reqResourcesVO.getResourcesType());
                proTransmissionStartupResourcesAssDao.insert(proTransmissionStartupResourcesAssEntity);
                uploadService.updateFileStatus(reqResourcesVO.getIdSysFiles());
            }
        }
        wrapper = new EntityWrapper<>();
        wrapper.eq("idx_pro_transmission",reqUpdatePowerTransmissionStartUpVO.getIdProTransmission());
        wrapper.eq("resources_type",3);

        if(ParametersUtil.isNotNull(reqUpdatePowerTransmissionStartUpVO.getAccessNetworkApprovalListFile())) {
            proTransmissionStartupResourcesAssDao.delete(wrapper);
            for (ReqResourcesVO reqResourcesVO : reqUpdatePowerTransmissionStartUpVO.getAccessNetworkApprovalListFile()) {
                ProTransmissionStartupResourcesAssEntity proTransmissionStartupResourcesAssEntity = new ProTransmissionStartupResourcesAssEntity();
                proTransmissionStartupResourcesAssEntity.setIdxProTransmission(proTransmissionStartupEntity.getIdProTransmission());
                proTransmissionStartupResourcesAssEntity.setIdxSysFiles(reqResourcesVO.getIdSysFiles());
                proTransmissionStartupResourcesAssEntity.setFilesType(1);
                proTransmissionStartupResourcesAssEntity.setResourcesType(3);
                proTransmissionStartupResourcesAssEntity.setStatus(1);
                proTransmissionStartupResourcesAssEntity.setCreateTime(date);
                proTransmissionStartupResourcesAssEntity.setUpdateTime(date);
                proTransmissionStartupResourcesAssDao.insert(proTransmissionStartupResourcesAssEntity);
                uploadService.updateFileStatus(reqResourcesVO.getIdSysFiles());
            }
        }

        ProTransmissionStartupEntity proTransmissionStartupEntity1 = proTransmissionStartupDao.selectById(reqUpdatePowerTransmissionStartUpVO.getIdProTransmission());
        addOrUpdateProStatus(proTransmissionStartupEntity1.getIdxProAdmin(),ProjectStatus.POWER_TRANSMISSION_START_UP.getValue(),reqUpdatePowerTransmissionStartUpVO.getSubmitState());


        if(reqUpdatePowerTransmissionStartUpVO.getSubmitState()!=null && reqUpdatePowerTransmissionStartUpVO.getSubmitState() ==3 ){
            updateStatus(proTransmissionStartupEntity1.getIdxProAdmin());
            //修改项目送电启动状态
            updateTransmissionStatus(proTransmissionStartupEntity1.getIdxProAdmin());
        }else if( !(reqUpdatePowerTransmissionStartUpVO.getSubmitState()!=null && reqUpdatePowerTransmissionStartUpVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqUpdatePowerTransmissionStartUpVO.getSubmitState());
            proAdmin.setIdProAdmin(proTransmissionStartupEntity1.getIdxProAdmin());
            proAdminDao.updateById(proAdmin);
        }
        return 1;
    }

    /**
     * 修改送电启动
     *
     * @param reqGetPowerTransmissionStartUpInfoVO
     * @return
     */
    @Override
    public ResGetPowerTransmissionStartUpInfoVO getPowerTransmissionStartUpInfo(ReqGetPowerTransmissionStartUpInfoVO reqGetPowerTransmissionStartUpInfoVO) {
        ResGetPowerTransmissionStartUpInfoVO resGetPowerTransmissionStartUpInfoVO = new ResGetPowerTransmissionStartUpInfoVO();

        ProTransmissionStartupEntity wrapper = new ProTransmissionStartupEntity();
        wrapper.setIdxProAdmin(reqGetPowerTransmissionStartUpInfoVO.getIdProAdmin());
        ProTransmissionStartupEntity proTransmissionStartupEntity = proTransmissionStartupDao.selectOne(wrapper);

        resGetPowerTransmissionStartUpInfoVO.setIdProTransmission(proTransmissionStartupEntity.getIdProTransmission());
        resGetPowerTransmissionStartUpInfoVO.setIdProAdmin(proTransmissionStartupEntity.getIdxProAdmin());

        //将资源表数据添加到返回对象中
        resGetPowerTransmissionStartUpInfoVO.setIdxSysFilesListFile(proTransmissionStartupResourcesAssDao.getFileList(proTransmissionStartupEntity.getIdProTransmission(),1));
        resGetPowerTransmissionStartUpInfoVO.setAccessNetworkApprovalListFile(proTransmissionStartupResourcesAssDao.getFileList(proTransmissionStartupEntity.getIdProTransmission(),2));
        resGetPowerTransmissionStartUpInfoVO.setCommissioningApprovalListFile(proTransmissionStartupResourcesAssDao.getFileList(proTransmissionStartupEntity.getIdProTransmission(),3));


        //获取项目状态
        ProStatusInfoAssEntity proStatusInfoAssEntity = getProStatus(proTransmissionStartupEntity.getIdxProAdmin(),
                ProjectStatus.POWER_TRANSMISSION_START_UP.getValue());
        resGetPowerTransmissionStartUpInfoVO.setStatus(proStatusInfoAssEntity.getStatus());
        resGetPowerTransmissionStartUpInfoVO.setSubmitState(proStatusInfoAssEntity.getSubmitState());
        return resGetPowerTransmissionStartUpInfoVO;
    }

    /**
     * 添加保护定值报送
     *
     * @param reqAddProtectionFixedValueReportingVO
     * @return
     */
    @Override
    @Transactional
    public Integer addProtectionFixedValueReporting(ReqAddProtectionFixedValueReportingVO reqAddProtectionFixedValueReportingVO) {
        FixedValueInsuredEntity fixedValueInsuredEntity  = new FixedValueInsuredEntity();
        fixedValueInsuredEntity.setIdxProAdmin(reqAddProtectionFixedValueReportingVO.getIdProAdmin());
        Date date = new Date();
        fixedValueInsuredEntity.setReportingDate(date);
        fixedValueInsuredEntity.setNameOfSubstation(reqAddProtectionFixedValueReportingVO.getNameOfSubstation());
        fixedValueInsuredEntity.setEquipmentChangeNature(reqAddProtectionFixedValueReportingVO.getEquipmentChangeNature());
        fixedValueInsuredEntity.setDeviceName(reqAddProtectionFixedValueReportingVO.getDeviceName());
        fixedValueInsuredEntity.setRegularImpedancePositiveSequence(reqAddProtectionFixedValueReportingVO.getRegularImpedancePositiveSequence());
        fixedValueInsuredEntity.setZeroSequence(reqAddProtectionFixedValueReportingVO.getZeroSequence());
        fixedValueInsuredEntity.setHighPressureSide(reqAddProtectionFixedValueReportingVO.getHighPressureSide());
        fixedValueInsuredEntity.setMediumPressureSide(reqAddProtectionFixedValueReportingVO.getMediumPressureSide());
        fixedValueInsuredEntity.setLowPressureSide(reqAddProtectionFixedValueReportingVO.getLowPressureSide());
        fixedValueInsuredEntity.setGaoYiZhong(reqAddProtectionFixedValueReportingVO.getGaoYiZhong());
        fixedValueInsuredEntity.setGaoYiDi(reqAddProtectionFixedValueReportingVO.getGaoYiDi());
        fixedValueInsuredEntity.setZhongYiDi(reqAddProtectionFixedValueReportingVO.getZhongYiDi());
        fixedValueInsuredEntity.setConnectionGroup(reqAddProtectionFixedValueReportingVO.getConnectionGroup());
        fixedValueInsuredEntity.setLoadingAndPressingForm(reqAddProtectionFixedValueReportingVO.getLoadingAndPressingForm());
        fixedValueInsuredEntity.setOnSiteVariationOfHighPressureSide(reqAddProtectionFixedValueReportingVO.getOnSiteVariationOfHighPressureSide());
        fixedValueInsuredEntity.setFieldVariationOfMediumPressureSide(reqAddProtectionFixedValueReportingVO.getFieldVariationOfMediumPressureSide());
        fixedValueInsuredEntity.setFieldVariationOfLowPressureSide(reqAddProtectionFixedValueReportingVO.getFieldVariationOfLowPressureSide());
        fixedValueInsuredEntity.setOnSiteVariationOfHighPressureSideInstallationLocation(reqAddProtectionFixedValueReportingVO.getOnSiteVariationOfHighPressureSideInstallationLocation());
        fixedValueInsuredEntity.setFieldVariationOfMediumPressureSideInstallationLocation(reqAddProtectionFixedValueReportingVO.getFieldVariationOfMediumPressureSideInstallationLocation());
        fixedValueInsuredEntity.setFieldVariationOfLowPressureSideInstallationLocation(reqAddProtectionFixedValueReportingVO.getFieldVariationOfLowPressureSideInstallationLocation());
        fixedValueInsuredEntity.setLineAndBranchNameOfPlatformChange(reqAddProtectionFixedValueReportingVO.getLineAndBranchNameOfPlatformChange());
        fixedValueInsuredEntity.setLoadProperty(reqAddProtectionFixedValueReportingVO.getLoadProperty());
        fixedValueInsuredEntity.setMaximumLoadCurrent(reqAddProtectionFixedValueReportingVO.getMaximumLoadCurrent());
        fixedValueInsuredEntity.setMaximumLoadVoltage(reqAddProtectionFixedValueReportingVO.getMaximumLoadVoltage());
        fixedValueInsuredEntity.setOperatingModeRequirements(reqAddProtectionFixedValueReportingVO.getOperatingModeRequirements());
        fixedValueInsuredEntity.setStatus(1);

        fixedValueInsuredEntity.setCreateTime(date);
        fixedValueInsuredEntity.setUpdateTime(date);
        fixedValueInsuredDao.insert(fixedValueInsuredEntity);

        if(ParametersUtil.isNotNull(reqAddProtectionFixedValueReportingVO.getFixedValueInsuredElectricAssList())) {
            for (ReqFixedValueInsuredElectricAssVO reqFixedValueInsuredElectricAssVO : reqAddProtectionFixedValueReportingVO.getFixedValueInsuredElectricAssList()) {
                FixedValueInsuredElectricAssEntity fixedValueInsuredElectricAssEntity = new FixedValueInsuredElectricAssEntity();
                fixedValueInsuredElectricAssEntity.setIdxFixedValueInsured(fixedValueInsuredEntity.getIdFixedValueInsured());
                fixedValueInsuredElectricAssEntity.setCapacity(reqFixedValueInsuredElectricAssVO.getCapacity());
                fixedValueInsuredElectricAssEntity.setRatedVoltage(reqFixedValueInsuredElectricAssVO.getRatedVoltage());
                fixedValueInsuredElectricAssEntity.setRatedCurrent(reqFixedValueInsuredElectricAssVO.getRatedCurrent());
                fixedValueInsuredElectricAssEntity.setCreateTime(date);
                fixedValueInsuredElectricAssEntity.setUpdateTime(date);
                fixedValueInsuredElectricAssDao.insert(fixedValueInsuredElectricAssEntity);
            }
        }

        if(ParametersUtil.isNotNull(reqAddProtectionFixedValueReportingVO.getFixedValueInsuredLineAssList())) {
            for (ReqFixedValueInsuredLineAssVO reqFixedValueInsuredLineAssVO : reqAddProtectionFixedValueReportingVO.getFixedValueInsuredLineAssList()) {
                FixedValueInsuredLineAssEntity fixedValueInsuredLineAssEntity = new FixedValueInsuredLineAssEntity();
                fixedValueInsuredLineAssEntity.setIdxFixedValueInsured(fixedValueInsuredEntity.getIdFixedValueInsured());
                fixedValueInsuredLineAssEntity.setModel(reqFixedValueInsuredLineAssVO.getModel());
                fixedValueInsuredLineAssEntity.setLength(reqFixedValueInsuredLineAssVO.getLength());
                fixedValueInsuredLineAssEntity.setSortedBy(reqFixedValueInsuredLineAssVO.getSortedBy());
                fixedValueInsuredLineAssEntity.setDistanceBetweenLines(reqFixedValueInsuredLineAssVO.getDistanceBetweenLines());
                fixedValueInsuredLineAssEntity.setTranspositionPoleNumberBox(reqFixedValueInsuredLineAssVO.getTranspositionPoleNumberBox());
                fixedValueInsuredLineAssEntity.setCreateTime(date);
                fixedValueInsuredLineAssEntity.setUpdateTime(date);
                fixedValueInsuredLineAssDao.insert(fixedValueInsuredLineAssEntity);
            }
        }

        if(ParametersUtil.isNotNull(reqAddProtectionFixedValueReportingVO.getFixedValueInsuredPtAssList())) {
            for (ReqFixedValueInsuredPtAssVO reqFixedValueInsuredPtAssVO : reqAddProtectionFixedValueReportingVO.getFixedValueInsuredPtAssList()) {
                FixedValueInsuredPtAssEntity fixedValueInsuredPtAssEntity = new FixedValueInsuredPtAssEntity();
                fixedValueInsuredPtAssEntity.setIdxFixedValueInsured(fixedValueInsuredEntity.getIdFixedValueInsured());
                fixedValueInsuredPtAssEntity.setConductorVoltage(reqFixedValueInsuredPtAssVO.getConductorVoltage());
                fixedValueInsuredPtAssEntity.setFieldApplicationOfVariableRatio(reqFixedValueInsuredPtAssVO.getFieldApplicationOfVariableRatio());
                fixedValueInsuredPtAssEntity.setPtInstallationLocation(reqFixedValueInsuredPtAssVO.getPtInstallationLocation());
                fixedValueInsuredPtAssEntity.setNameOfSubstation(reqFixedValueInsuredPtAssVO.getNameOfSubstation());
                fixedValueInsuredPtAssEntity.setCreateTime(date);
                fixedValueInsuredPtAssEntity.setUpdateTime(date);
                fixedValueInsuredPtAssDao.insert(fixedValueInsuredPtAssEntity);
            }
        }

        if(ParametersUtil.isNotNull(reqAddProtectionFixedValueReportingVO.getFixedValueInsuredTransformerNameplateAssList())) {
            for (ReqFixedValueInsuredTransformerNameplateAssVO reqFixedValueInsuredTransformerNameplateAssVO : reqAddProtectionFixedValueReportingVO.getFixedValueInsuredTransformerNameplateAssList()) {
                FixedValueInsuredTransformerNameplateAssEntity fixedValueInsuredTransformerNameplateAssEntity = new FixedValueInsuredTransformerNameplateAssEntity();
                fixedValueInsuredTransformerNameplateAssEntity.setSeparately(reqFixedValueInsuredTransformerNameplateAssVO.getSeparately());
                fixedValueInsuredTransformerNameplateAssEntity.setHighVoltage(reqFixedValueInsuredTransformerNameplateAssVO.getHighVoltage());
                fixedValueInsuredTransformerNameplateAssEntity.setHighVoltageCurrent(reqFixedValueInsuredTransformerNameplateAssVO.getHighVoltageCurrent());
                fixedValueInsuredTransformerNameplateAssEntity.setVoltage(reqFixedValueInsuredTransformerNameplateAssVO.getVoltage());
                fixedValueInsuredTransformerNameplateAssEntity.setVoltageCurrent(reqFixedValueInsuredTransformerNameplateAssVO.getVoltageCurrent());
                fixedValueInsuredTransformerNameplateAssEntity.setLowVoltage(reqFixedValueInsuredTransformerNameplateAssVO.getLowVoltage());
                fixedValueInsuredTransformerNameplateAssEntity.setLowVoltageCurrent(reqFixedValueInsuredTransformerNameplateAssVO.getLowVoltageCurrent());
                fixedValueInsuredTransformerNameplateAssEntity.setCreateTime(date);
                fixedValueInsuredTransformerNameplateAssEntity.setUpdateTime(date);
                fixedValueInsuredTransformerNameplateAssDao.insert(fixedValueInsuredTransformerNameplateAssEntity);
            }
        }

        addOrUpdateProStatus(reqAddProtectionFixedValueReportingVO.getIdProAdmin(),ProjectStatus.PROTECTION_FIXED_VALUE_REPORTING.getValue(),reqAddProtectionFixedValueReportingVO.getSubmitState());

        if(reqAddProtectionFixedValueReportingVO.getSubmitState()!=null && reqAddProtectionFixedValueReportingVO.getSubmitState() ==3 ){
            updateStatus(reqAddProtectionFixedValueReportingVO.getIdProAdmin());
        }else if( !(reqAddProtectionFixedValueReportingVO.getSubmitState()!=null && reqAddProtectionFixedValueReportingVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqAddProtectionFixedValueReportingVO.getSubmitState());
            proAdmin.setIdProAdmin(reqAddProtectionFixedValueReportingVO.getIdProAdmin());
            proAdminDao.updateById(proAdmin);
        }
        return 1;
    }

    /**
     * 修改保护定值报送
     *
     * @param reqUpdateProtectionFixedValueReportingVO
     * @return
     */
    @Override
    @Transactional
    public Integer updateProtectionFixedValueReporting(ReqUpdateProtectionFixedValueReportingVO reqUpdateProtectionFixedValueReportingVO) {
        FixedValueInsuredEntity fixedValueInsuredEntity  = new FixedValueInsuredEntity();
        fixedValueInsuredEntity.setNameOfSubstation(reqUpdateProtectionFixedValueReportingVO.getNameOfSubstation());
        fixedValueInsuredEntity.setEquipmentChangeNature(reqUpdateProtectionFixedValueReportingVO.getEquipmentChangeNature());
        fixedValueInsuredEntity.setDeviceName(reqUpdateProtectionFixedValueReportingVO.getDeviceName());
        fixedValueInsuredEntity.setRegularImpedancePositiveSequence(reqUpdateProtectionFixedValueReportingVO.getRegularImpedancePositiveSequence());
        fixedValueInsuredEntity.setZeroSequence(reqUpdateProtectionFixedValueReportingVO.getZeroSequence());
        fixedValueInsuredEntity.setHighPressureSide(reqUpdateProtectionFixedValueReportingVO.getHighPressureSide());
        fixedValueInsuredEntity.setMediumPressureSide(reqUpdateProtectionFixedValueReportingVO.getMediumPressureSide());
        fixedValueInsuredEntity.setLowPressureSide(reqUpdateProtectionFixedValueReportingVO.getLowPressureSide());
        fixedValueInsuredEntity.setGaoYiZhong(reqUpdateProtectionFixedValueReportingVO.getGaoYiZhong());
        fixedValueInsuredEntity.setGaoYiDi(reqUpdateProtectionFixedValueReportingVO.getGaoYiDi());
        fixedValueInsuredEntity.setZhongYiDi(reqUpdateProtectionFixedValueReportingVO.getZhongYiDi());
        fixedValueInsuredEntity.setConnectionGroup(reqUpdateProtectionFixedValueReportingVO.getConnectionGroup());
        fixedValueInsuredEntity.setLoadingAndPressingForm(reqUpdateProtectionFixedValueReportingVO.getLoadingAndPressingForm());
        fixedValueInsuredEntity.setOnSiteVariationOfHighPressureSide(reqUpdateProtectionFixedValueReportingVO.getOnSiteVariationOfHighPressureSide());
        fixedValueInsuredEntity.setFieldVariationOfMediumPressureSide(reqUpdateProtectionFixedValueReportingVO.getFieldVariationOfMediumPressureSide());
        fixedValueInsuredEntity.setFieldVariationOfLowPressureSide(reqUpdateProtectionFixedValueReportingVO.getFieldVariationOfLowPressureSide());
        fixedValueInsuredEntity.setOnSiteVariationOfHighPressureSideInstallationLocation(reqUpdateProtectionFixedValueReportingVO.getOnSiteVariationOfHighPressureSideInstallationLocation());
        fixedValueInsuredEntity.setFieldVariationOfMediumPressureSideInstallationLocation(reqUpdateProtectionFixedValueReportingVO.getFieldVariationOfMediumPressureSideInstallationLocation());
        fixedValueInsuredEntity.setFieldVariationOfLowPressureSideInstallationLocation(reqUpdateProtectionFixedValueReportingVO.getFieldVariationOfLowPressureSideInstallationLocation());
        fixedValueInsuredEntity.setLineAndBranchNameOfPlatformChange(reqUpdateProtectionFixedValueReportingVO.getLineAndBranchNameOfPlatformChange());
        fixedValueInsuredEntity.setLoadProperty(reqUpdateProtectionFixedValueReportingVO.getLoadProperty());
        fixedValueInsuredEntity.setMaximumLoadCurrent(reqUpdateProtectionFixedValueReportingVO.getMaximumLoadCurrent());
        fixedValueInsuredEntity.setMaximumLoadVoltage(reqUpdateProtectionFixedValueReportingVO.getMaximumLoadVoltage());
        fixedValueInsuredEntity.setOperatingModeRequirements(reqUpdateProtectionFixedValueReportingVO.getOperatingModeRequirements());
        fixedValueInsuredEntity.setStatus(1);
        Date date = new Date();
        fixedValueInsuredEntity.setUpdateTime(date);
        fixedValueInsuredEntity.setIdFixedValueInsured(reqUpdateProtectionFixedValueReportingVO.getIdFixedValueInsured());
        fixedValueInsuredDao.updateById(fixedValueInsuredEntity);




        Wrapper wrapper = new EntityWrapper<FixedValueInsuredElectricAssEntity>();
        if(ParametersUtil.isNotNull(reqUpdateProtectionFixedValueReportingVO.getFixedValueInsuredElectricAssList()) && reqUpdateProtectionFixedValueReportingVO.getFixedValueInsuredElectricAssList().size() > 0) {
            wrapper.eq("idx_fixed_value_insured",reqUpdateProtectionFixedValueReportingVO.getIdFixedValueInsured());
            fixedValueInsuredElectricAssDao.delete(wrapper);
            for (ReqFixedValueInsuredElectricAssVO reqFixedValueInsuredElectricAssVO : reqUpdateProtectionFixedValueReportingVO.getFixedValueInsuredElectricAssList()) {
                FixedValueInsuredElectricAssEntity fixedValueInsuredElectricAssEntity = new FixedValueInsuredElectricAssEntity();
                fixedValueInsuredElectricAssEntity.setIdxFixedValueInsured(fixedValueInsuredEntity.getIdFixedValueInsured());
                fixedValueInsuredElectricAssEntity.setCapacity(reqFixedValueInsuredElectricAssVO.getCapacity());
                fixedValueInsuredElectricAssEntity.setRatedVoltage(reqFixedValueInsuredElectricAssVO.getRatedVoltage());
                fixedValueInsuredElectricAssEntity.setRatedCurrent(reqFixedValueInsuredElectricAssVO.getRatedCurrent());
                fixedValueInsuredElectricAssEntity.setCreateTime(date);
                fixedValueInsuredElectricAssEntity.setUpdateTime(date);
                fixedValueInsuredElectricAssDao.insert(fixedValueInsuredElectricAssEntity);
            }
        }

        wrapper = new EntityWrapper<FixedValueInsuredLineAssEntity>();
        if(ParametersUtil.isNotNull(reqUpdateProtectionFixedValueReportingVO.getFixedValueInsuredLineAssList())  && reqUpdateProtectionFixedValueReportingVO.getFixedValueInsuredLineAssList().size() > 0) {
            wrapper.eq("idx_fixed_value_insured",reqUpdateProtectionFixedValueReportingVO.getIdFixedValueInsured());
            fixedValueInsuredLineAssDao.delete(wrapper);
            for (ReqFixedValueInsuredLineAssVO reqFixedValueInsuredLineAssVO : reqUpdateProtectionFixedValueReportingVO.getFixedValueInsuredLineAssList()) {
                FixedValueInsuredLineAssEntity fixedValueInsuredLineAssEntity = new FixedValueInsuredLineAssEntity();
                fixedValueInsuredLineAssEntity.setIdxFixedValueInsured(fixedValueInsuredEntity.getIdFixedValueInsured());
                fixedValueInsuredLineAssEntity.setModel(reqFixedValueInsuredLineAssVO.getModel());
                fixedValueInsuredLineAssEntity.setLength(reqFixedValueInsuredLineAssVO.getLength());
                fixedValueInsuredLineAssEntity.setSortedBy(reqFixedValueInsuredLineAssVO.getSortedBy());
                fixedValueInsuredLineAssEntity.setDistanceBetweenLines(reqFixedValueInsuredLineAssVO.getDistanceBetweenLines());
                fixedValueInsuredLineAssEntity.setTranspositionPoleNumberBox(reqFixedValueInsuredLineAssVO.getTranspositionPoleNumberBox());
                fixedValueInsuredLineAssEntity.setCreateTime(date);
                fixedValueInsuredLineAssEntity.setUpdateTime(date);
                fixedValueInsuredLineAssDao.insert(fixedValueInsuredLineAssEntity);
            }
        }

        wrapper = new EntityWrapper<FixedValueInsuredPtAssEntity>();
        if(ParametersUtil.isNotNull(reqUpdateProtectionFixedValueReportingVO.getFixedValueInsuredPtAssList()) && reqUpdateProtectionFixedValueReportingVO.getFixedValueInsuredPtAssList().size() > 0) {
            wrapper.eq("idx_fixed_value_insured",reqUpdateProtectionFixedValueReportingVO.getIdFixedValueInsured());
            fixedValueInsuredPtAssDao.delete(wrapper);
            for (ReqFixedValueInsuredPtAssVO reqFixedValueInsuredPtAssVO : reqUpdateProtectionFixedValueReportingVO.getFixedValueInsuredPtAssList()) {
                FixedValueInsuredPtAssEntity fixedValueInsuredPtAssEntity = new FixedValueInsuredPtAssEntity();
                fixedValueInsuredPtAssEntity.setIdxFixedValueInsured(fixedValueInsuredEntity.getIdFixedValueInsured());
                fixedValueInsuredPtAssEntity.setConductorVoltage(reqFixedValueInsuredPtAssVO.getConductorVoltage());
                fixedValueInsuredPtAssEntity.setFieldApplicationOfVariableRatio(reqFixedValueInsuredPtAssVO.getFieldApplicationOfVariableRatio());
                fixedValueInsuredPtAssEntity.setPtInstallationLocation(reqFixedValueInsuredPtAssVO.getPtInstallationLocation());
                fixedValueInsuredPtAssEntity.setNameOfSubstation(reqFixedValueInsuredPtAssVO.getNameOfSubstation());
                fixedValueInsuredPtAssEntity.setCreateTime(date);
                fixedValueInsuredPtAssEntity.setUpdateTime(date);
                fixedValueInsuredPtAssDao.insert(fixedValueInsuredPtAssEntity);
            }
        }

        wrapper = new EntityWrapper<FixedValueInsuredTransformerNameplateAssEntity>();
        if(ParametersUtil.isNotNull(reqUpdateProtectionFixedValueReportingVO.getFixedValueInsuredTransformerNameplateAssList()) && reqUpdateProtectionFixedValueReportingVO.getFixedValueInsuredTransformerNameplateAssList().size() > 0) {
            wrapper.eq("idx_fixed_value_insured",reqUpdateProtectionFixedValueReportingVO.getIdFixedValueInsured() );
            fixedValueInsuredTransformerNameplateAssDao.delete(wrapper);
            for (ReqFixedValueInsuredTransformerNameplateAssVO reqFixedValueInsuredTransformerNameplateAssVO : reqUpdateProtectionFixedValueReportingVO.getFixedValueInsuredTransformerNameplateAssList()) {
                FixedValueInsuredTransformerNameplateAssEntity fixedValueInsuredTransformerNameplateAssEntity = new FixedValueInsuredTransformerNameplateAssEntity();
                fixedValueInsuredTransformerNameplateAssEntity.setSeparately(reqFixedValueInsuredTransformerNameplateAssVO.getSeparately());
                fixedValueInsuredTransformerNameplateAssEntity.setIdxFixedValueInsured(fixedValueInsuredEntity.getIdFixedValueInsured());
                fixedValueInsuredTransformerNameplateAssEntity.setHighVoltage(reqFixedValueInsuredTransformerNameplateAssVO.getHighVoltage());
                fixedValueInsuredTransformerNameplateAssEntity.setHighVoltageCurrent(reqFixedValueInsuredTransformerNameplateAssVO.getHighVoltageCurrent());
                fixedValueInsuredTransformerNameplateAssEntity.setVoltage(reqFixedValueInsuredTransformerNameplateAssVO.getVoltage());
                fixedValueInsuredTransformerNameplateAssEntity.setVoltageCurrent(reqFixedValueInsuredTransformerNameplateAssVO.getVoltageCurrent());
                fixedValueInsuredTransformerNameplateAssEntity.setLowVoltage(reqFixedValueInsuredTransformerNameplateAssVO.getLowVoltage());
                fixedValueInsuredTransformerNameplateAssEntity.setLowVoltageCurrent(reqFixedValueInsuredTransformerNameplateAssVO.getLowVoltageCurrent());
                fixedValueInsuredTransformerNameplateAssEntity.setCreateTime(date);
                fixedValueInsuredTransformerNameplateAssEntity.setUpdateTime(date);
                fixedValueInsuredTransformerNameplateAssDao.insert(fixedValueInsuredTransformerNameplateAssEntity);
            }
        }

        FixedValueInsuredEntity fixedValueInsuredEntity1 = fixedValueInsuredDao.selectById(reqUpdateProtectionFixedValueReportingVO.getIdFixedValueInsured());
        if(ParametersUtil.isNotNull(reqUpdateProtectionFixedValueReportingVO.getSubmitState())){
            addOrUpdateProStatus(fixedValueInsuredEntity1.getIdxProAdmin(),ProjectStatus.PROTECTION_FIXED_VALUE_REPORTING.getValue(),reqUpdateProtectionFixedValueReportingVO.getSubmitState());

            if(reqUpdateProtectionFixedValueReportingVO.getSubmitState()!=null && reqUpdateProtectionFixedValueReportingVO.getSubmitState() ==3 ){
                updateStatus(fixedValueInsuredEntity1.getIdxProAdmin());
            }else if( !(reqUpdateProtectionFixedValueReportingVO.getSubmitState()!=null && reqUpdateProtectionFixedValueReportingVO.getSubmitState() == 0) ){
                ProAdminEntity proAdmin = new ProAdminEntity();
                proAdmin.setSubmitState(reqUpdateProtectionFixedValueReportingVO.getSubmitState());
                proAdmin.setIdProAdmin(fixedValueInsuredEntity1.getIdxProAdmin());
                proAdminDao.updateById(proAdmin);
            }
        }

        return 1;
    }

    /**
     * 获取保护定值报送信息
     *
     * @param reqGetProtectionFixedValueReportingVO
     * @return
     */
    @Override
    public ResGetProtectionFixedValueReportingInfoVO getProtectionFixedValueReportingInfo(ReqGetProtectionFixedValueReportingVO reqGetProtectionFixedValueReportingVO) {
        ResGetProtectionFixedValueReportingInfoVO resGetProtectionFixedValueReportingInfoVO = fixedValueInsuredDao.getProtectionFixedValueReportingInfo(reqGetProtectionFixedValueReportingVO);
        resGetProtectionFixedValueReportingInfoVO.setFixedValueInsuredElectricAssList(fixedValueInsuredElectricAssDao.getFixedValueInsuredElectricAssList(resGetProtectionFixedValueReportingInfoVO.getIdFixedValueInsured()));
        resGetProtectionFixedValueReportingInfoVO.setFixedValueInsuredLineAssList(fixedValueInsuredLineAssDao.getFixedValueInsuredLineAssList(resGetProtectionFixedValueReportingInfoVO.getIdFixedValueInsured()));
        resGetProtectionFixedValueReportingInfoVO.setFixedValueInsuredPtAssList(fixedValueInsuredPtAssDao.getFixedValueInsuredPtAssList(resGetProtectionFixedValueReportingInfoVO.getIdFixedValueInsured()));
        resGetProtectionFixedValueReportingInfoVO.setFixedValueInsuredTransformerNameplateAssList(fixedValueInsuredTransformerNameplateAssDao.getFixedValueInsuredTransformerNameplateAssList(resGetProtectionFixedValueReportingInfoVO.getIdFixedValueInsured()));

        //获取项目状态
        ProStatusInfoAssEntity proStatusInfoAssEntity = getProStatus(reqGetProtectionFixedValueReportingVO.getIdProAdmin(),
                ProjectStatus.PROTECTION_FIXED_VALUE_REPORTING.getValue());
        resGetProtectionFixedValueReportingInfoVO.setStatus(proStatusInfoAssEntity.getStatus());
        resGetProtectionFixedValueReportingInfoVO.setSubmitState(proStatusInfoAssEntity.getSubmitState());
        return resGetProtectionFixedValueReportingInfoVO;
    }

    /**
     * 添加供电方案
     *
     * @param reqAddPowerSupplySchemeVO
     * @return
     */
    @Override
    @Transactional
    public Integer addPowerSupplyScheme(ReqAddPowerSupplySchemeVO reqAddPowerSupplySchemeVO) {
        ProPowerSupplySchemeEntity proPowerSupplySchemeEntity = new ProPowerSupplySchemeEntity();
        proPowerSupplySchemeEntity.setIdxProAdmin(reqAddPowerSupplySchemeVO.getIdProAdmin());
        proPowerSupplySchemeEntity.setCustomerType(reqAddPowerSupplySchemeVO.getCustomerType());
        proPowerSupplySchemeEntity.setProgrammeType(reqAddPowerSupplySchemeVO.getProgrammeType());
        proPowerSupplySchemeEntity.setWorkOrderNumber(reqAddPowerSupplySchemeVO.getWorkOrderNumber());
        proPowerSupplySchemeEntity.setCustomerLevel(reqAddPowerSupplySchemeVO.getCustomerLevel());
        proPowerSupplySchemeEntity.setIndustryType(reqAddPowerSupplySchemeVO.getIndustryType());
        proPowerSupplySchemeEntity.setLoadType(reqAddPowerSupplySchemeVO.getLoadType());
        proPowerSupplySchemeEntity.setPowerSupplyVoltage(reqAddPowerSupplySchemeVO.getPowerSupplyVoltage());
        proPowerSupplySchemeEntity.setLayingLines(reqAddPowerSupplySchemeVO.getLayingLines());
        proPowerSupplySchemeEntity.setElectricityType(reqAddPowerSupplySchemeVO.getElectricityType());
        proPowerSupplySchemeEntity.setIsDesign(reqAddPowerSupplySchemeVO.getIsDesign());
        proPowerSupplySchemeEntity.setEngineeringType(reqAddPowerSupplySchemeVO.getEngineeringType());
        proPowerSupplySchemeEntity.setMeteringType(reqAddPowerSupplySchemeVO.getMeteringType());
        proPowerSupplySchemeEntity.setCalculationLoss(reqAddPowerSupplySchemeVO.getCalculationLoss());
        proPowerSupplySchemeEntity.setCalculationLineLoss(reqAddPowerSupplySchemeVO.getCalculationLineLoss());
        proPowerSupplySchemeEntity.setProductionControl(reqAddPowerSupplySchemeVO.getProductionControl());
        proPowerSupplySchemeEntity.setOperatingUnit(reqAddPowerSupplySchemeVO.getOperatingUnit());
        proPowerSupplySchemeEntity.setAddUpdateOccupy(reqAddPowerSupplySchemeVO.getAddUpdateOccupy());
        proPowerSupplySchemeEntity.setHFeeStandard(reqAddPowerSupplySchemeVO.getHFeeStandard());
        proPowerSupplySchemeEntity.setHCollectionCapacity(reqAddPowerSupplySchemeVO.getHCollectionCapacity());
        proPowerSupplySchemeEntity.setHAmountReceivable(reqAddPowerSupplySchemeVO.getHAmountReceivable());
        proPowerSupplySchemeEntity.setExplorers(reqAddPowerSupplySchemeVO.getExplorers());
        proPowerSupplySchemeEntity.setApplicationSubmitTime(reqAddPowerSupplySchemeVO.getApplicationSubmitTime());
        proPowerSupplySchemeEntity.setApplicationSubmitType(reqAddPowerSupplySchemeVO.getApplicationSubmitType());
        proPowerSupplySchemeEntity.setApplicationSubmitExplain(reqAddPowerSupplySchemeVO.getApplicationSubmitExplain());
        proPowerSupplySchemeEntity.setCustomerManager(reqAddPowerSupplySchemeVO.getCustomerManager());
        proPowerSupplySchemeEntity.setCustomerEngineer(reqAddPowerSupplySchemeVO.getCustomerEngineer());


        proPowerSupplySchemeEntity.setPowerSupplyDiagram(reqAddPowerSupplySchemeVO.getPowerSupplyDiagram());
        proPowerSupplySchemeEntity.setPowerSupplyFinal(reqAddPowerSupplySchemeVO.getPowerSupplyFinal());
        proPowerSupplySchemeEntity.setEnclosureFile(reqAddPowerSupplySchemeVO.getEnclosureFile());


        Date date = new Date();
        proPowerSupplySchemeEntity.setCreateTime(date);
        proPowerSupplySchemeEntity.setUpdateTime(date);
        proPowerSupplySchemeEntity.setStatus(1);

        proPowerSupplySchemeDao.insert(proPowerSupplySchemeEntity);

        uploadService.updateFileStatus(reqAddPowerSupplySchemeVO.getPowerSupplyDiagram());
        uploadService.updateFileStatus(reqAddPowerSupplySchemeVO.getPowerSupplyFinal());
        uploadService.updateFileStatus(reqAddPowerSupplySchemeVO.getEnclosureFile());

        if(ParametersUtil.isNotNull(reqAddPowerSupplySchemeVO.getProPowerSupplySchemeElectricityPriceList())){
            for (ReqProPowerSupplySchemeElectricityPriceAssVO reqProPowerSupplySchemeElectricityPriceAssVO : reqAddPowerSupplySchemeVO.getProPowerSupplySchemeElectricityPriceList()) {
                ProPowerSupplySchemeElectricityPriceAssEntity proPowerSupplySchemeElectricityPriceAssEntity = new ProPowerSupplySchemeElectricityPriceAssEntity();
                proPowerSupplySchemeElectricityPriceAssEntity.setIdxProPowerSupplyScheme(proPowerSupplySchemeEntity.getIdProPowerSupplyScheme());
                proPowerSupplySchemeElectricityPriceAssEntity.setElectricityPriceOne(reqProPowerSupplySchemeElectricityPriceAssVO.getElectricityPriceOne());
                proPowerSupplySchemeElectricityPriceAssEntity.setElectricityPriceTwo(reqProPowerSupplySchemeElectricityPriceAssVO.getElectricityPriceTwo());
                proPowerSupplySchemeElectricityPriceAssEntity.setElectricityPriceStandard(reqProPowerSupplySchemeElectricityPriceAssVO.getElectricityPriceStandard());
                proPowerSupplySchemeElectricityPriceAssDao.insert(proPowerSupplySchemeElectricityPriceAssEntity);
            }
        }
        if(ParametersUtil.isNotNull(reqAddPowerSupplySchemeVO.getProPowerSupplySchemeMeteringList())){
            for (ReqProPowerSupplySchemeMeteringAssVO reqProPowerSupplySchemeMeteringAssVO : reqAddPowerSupplySchemeVO.getProPowerSupplySchemeMeteringList()) {
                ProPowerSupplySchemeMeteringAssEntity proPowerSupplySchemeMeteringAssEntity = new ProPowerSupplySchemeMeteringAssEntity();
                proPowerSupplySchemeMeteringAssEntity.setIdxProPowerSupplyScheme(proPowerSupplySchemeEntity.getIdProPowerSupplyScheme());
                proPowerSupplySchemeMeteringAssEntity.setMeteringSpotCount(reqProPowerSupplySchemeMeteringAssVO.getMeteringSpotCount());
                proPowerSupplySchemeMeteringAssEntity.setInstallationLocation(reqProPowerSupplySchemeMeteringAssVO.getInstallationLocation());
                proPowerSupplySchemeMeteringAssEntity.setDataCommunicationWay(reqProPowerSupplySchemeMeteringAssVO.getDataCommunicationWay());
                proPowerSupplySchemeMeteringAssEntity.setMeteringWay(reqProPowerSupplySchemeMeteringAssVO.getMeteringWay());
                proPowerSupplySchemeMeteringAssEntity.setConnectionMode(reqProPowerSupplySchemeMeteringAssVO.getConnectionMode());
                proPowerSupplySchemeMeteringAssEntity.setMeteringSpotVoltage(reqProPowerSupplySchemeMeteringAssVO.getMeteringSpotVoltage());
                proPowerSupplySchemeMeteringAssEntity.setTerminalType(reqProPowerSupplySchemeMeteringAssVO.getTerminalType());
                proPowerSupplySchemeMeteringAssEntity.setEnergyMeterType(reqProPowerSupplySchemeMeteringAssVO.getEnergyMeterType());
                proPowerSupplySchemeMeteringAssEntity.setEnergyMeterVoltage(reqProPowerSupplySchemeMeteringAssVO.getEnergyMeterVoltage());
                proPowerSupplySchemeMeteringAssEntity.setEnergyMeterElectric(reqProPowerSupplySchemeMeteringAssVO.getEnergyMeterElectric());
                proPowerSupplySchemeMeteringAssEntity.setEnergyMeterAccuracy(reqProPowerSupplySchemeMeteringAssVO.getEnergyMeterAccuracy());
                proPowerSupplySchemeMeteringAssEntity.setVoltageMutualInductorVoltage(reqProPowerSupplySchemeMeteringAssVO.getVoltageMutualInductorVoltage());
                proPowerSupplySchemeMeteringAssEntity.setVoltageMutualInductorVariableRatio(reqProPowerSupplySchemeMeteringAssVO.getVoltageMutualInductorVariableRatio());
                proPowerSupplySchemeMeteringAssEntity.setVoltageMutualInductorAccuracy(reqProPowerSupplySchemeMeteringAssVO.getVoltageMutualInductorAccuracy());
                proPowerSupplySchemeMeteringAssEntity.setVoltageMutualInductorCount(reqProPowerSupplySchemeMeteringAssVO.getVoltageMutualInductorCount());
                proPowerSupplySchemeMeteringAssEntity.setElectricMutualInductorVoltage(reqProPowerSupplySchemeMeteringAssVO.getElectricMutualInductorVoltage());
                proPowerSupplySchemeMeteringAssEntity.setElectricMutualInductorVariableRatio(reqProPowerSupplySchemeMeteringAssVO.getElectricMutualInductorVariableRatio());
                proPowerSupplySchemeMeteringAssEntity.setElectricMutualInductorAccuracy(reqProPowerSupplySchemeMeteringAssVO.getElectricMutualInductorAccuracy());
                proPowerSupplySchemeMeteringAssEntity.setElectricMutualInductorCount(reqProPowerSupplySchemeMeteringAssVO.getElectricMutualInductorCount());
                proPowerSupplySchemeMeteringAssEntity.setMeteringTerminalLocation(reqProPowerSupplySchemeMeteringAssVO.getMeteringTerminalLocation());
                proPowerSupplySchemeMeteringAssEntity.setMeteringTerminalAccuracy(reqProPowerSupplySchemeMeteringAssVO.getMeteringTerminalAccuracy());
                proPowerSupplySchemeMeteringAssEntity.setMeteringTerminalCount(reqProPowerSupplySchemeMeteringAssVO.getMeteringTerminalCount());
                proPowerSupplySchemeMeteringAssDao.insert(proPowerSupplySchemeMeteringAssEntity);
            }
        }


        if(ParametersUtil.isNotNull(reqAddPowerSupplySchemeVO.getProPowerSupplySchemePowerAssList())){
            for (ReqProPowerSupplySchemePowerAssVO reqProPowerSupplySchemePowerAssVO : reqAddPowerSupplySchemeVO.getProPowerSupplySchemePowerAssList()) {
                ProPowerSupplySchemePowerAssEntity proPowerSupplySchemePowerAssEntity = new ProPowerSupplySchemePowerAssEntity();
                proPowerSupplySchemePowerAssEntity.setIdxProPowerSupplyScheme(proPowerSupplySchemeEntity.getIdProPowerSupplyScheme());
                proPowerSupplySchemePowerAssEntity.setPowerSupply(reqProPowerSupplySchemePowerAssVO.getPowerSupply());
                proPowerSupplySchemePowerAssEntity.setPowerProperties(reqProPowerSupplySchemePowerAssVO.getPowerProperties());
                proPowerSupplySchemePowerAssEntity.setPowerType(reqProPowerSupplySchemePowerAssVO.getPowerType());
                proPowerSupplySchemePowerAssEntity.setPowerVoltage(reqProPowerSupplySchemePowerAssVO.getPowerVoltage());
                proPowerSupplySchemePowerAssEntity.setPowerCapacity(reqProPowerSupplySchemePowerAssVO.getPowerCapacity());
                proPowerSupplySchemePowerAssEntity.setLineParameters1(reqProPowerSupplySchemePowerAssVO.getLineParameters1());
                proPowerSupplySchemePowerAssEntity.setLineParameters2(reqProPowerSupplySchemePowerAssVO.getLineParameters2());
                proPowerSupplySchemePowerAssEntity.setLayingMethod(reqProPowerSupplySchemePowerAssVO.getLayingMethod());
                proPowerSupplySchemePowerAssEntity.setGroundingMode(reqProPowerSupplySchemePowerAssVO.getGroundingMode());
                proPowerSupplySchemePowerAssEntity.setShortCircuitCapacity(reqProPowerSupplySchemePowerAssVO.getShortCircuitCapacity());
                proPowerSupplySchemePowerAssEntity.setPointPropertyRight(reqProPowerSupplySchemePowerAssVO.getPointPropertyRight());
                proPowerSupplySchemePowerAssDao.insert(proPowerSupplySchemePowerAssEntity);
            }
        }

        addOrUpdateProStatus(reqAddPowerSupplySchemeVO.getIdProAdmin(),ProjectStatus.POWER_SUPPLY_SCHEME.getValue(),reqAddPowerSupplySchemeVO.getSubmitState());

        if(reqAddPowerSupplySchemeVO.getSubmitState()!=null && reqAddPowerSupplySchemeVO.getSubmitState() ==3 ){
            updateStatus(reqAddPowerSupplySchemeVO.getIdProAdmin());
        }else if( !(reqAddPowerSupplySchemeVO.getSubmitState()!=null && reqAddPowerSupplySchemeVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqAddPowerSupplySchemeVO.getSubmitState());
            proAdmin.setIdProAdmin(reqAddPowerSupplySchemeVO.getIdProAdmin());
            proAdminDao.updateById(proAdmin);
        }

        return 1;
    }

    /**
     * 修改供电方案
     *
     * @param reqUpdatePowerSupplySchemeVO
     * @return
     */
    @Override
    public Integer updatePowerSupplyScheme(ReqUpdatePowerSupplySchemeVO reqUpdatePowerSupplySchemeVO) {
        ProPowerSupplySchemeEntity proPowerSupplySchemeEntity = new ProPowerSupplySchemeEntity();
        proPowerSupplySchemeEntity.setCustomerType(reqUpdatePowerSupplySchemeVO.getCustomerType());
        proPowerSupplySchemeEntity.setProgrammeType(reqUpdatePowerSupplySchemeVO.getProgrammeType());
        proPowerSupplySchemeEntity.setWorkOrderNumber(reqUpdatePowerSupplySchemeVO.getWorkOrderNumber());
        proPowerSupplySchemeEntity.setCustomerLevel(reqUpdatePowerSupplySchemeVO.getCustomerLevel());
        proPowerSupplySchemeEntity.setIndustryType(reqUpdatePowerSupplySchemeVO.getIndustryType());
        proPowerSupplySchemeEntity.setLoadType(reqUpdatePowerSupplySchemeVO.getLoadType());
        proPowerSupplySchemeEntity.setPowerSupplyVoltage(reqUpdatePowerSupplySchemeVO.getPowerSupplyVoltage());
        proPowerSupplySchemeEntity.setLayingLines(reqUpdatePowerSupplySchemeVO.getLayingLines());
        proPowerSupplySchemeEntity.setEngineeringType(reqUpdatePowerSupplySchemeVO.getEngineeringType());
        proPowerSupplySchemeEntity.setIsDesign(reqUpdatePowerSupplySchemeVO.getIsDesign());
        proPowerSupplySchemeEntity.setEngineeringType(reqUpdatePowerSupplySchemeVO.getEngineeringType());
        proPowerSupplySchemeEntity.setMeteringType(reqUpdatePowerSupplySchemeVO.getMeteringType());
        proPowerSupplySchemeEntity.setCalculationLoss(reqUpdatePowerSupplySchemeVO.getCalculationLoss());
        proPowerSupplySchemeEntity.setCalculationLineLoss(reqUpdatePowerSupplySchemeVO.getCalculationLineLoss());
        proPowerSupplySchemeEntity.setProductionControl(reqUpdatePowerSupplySchemeVO.getProductionControl());
        proPowerSupplySchemeEntity.setOperatingUnit(reqUpdatePowerSupplySchemeVO.getOperatingUnit());
        proPowerSupplySchemeEntity.setAddUpdateOccupy(reqUpdatePowerSupplySchemeVO.getAddUpdateOccupy());
        proPowerSupplySchemeEntity.setHFeeStandard(reqUpdatePowerSupplySchemeVO.getHFeeStandard());
        proPowerSupplySchemeEntity.setHCollectionCapacity(reqUpdatePowerSupplySchemeVO.getHCollectionCapacity());
        proPowerSupplySchemeEntity.setHAmountReceivable(reqUpdatePowerSupplySchemeVO.getHAmountReceivable());
        proPowerSupplySchemeEntity.setExplorers(reqUpdatePowerSupplySchemeVO.getExplorers());
        proPowerSupplySchemeEntity.setApplicationSubmitTime(reqUpdatePowerSupplySchemeVO.getApplicationSubmitTime());
        proPowerSupplySchemeEntity.setApplicationSubmitType(reqUpdatePowerSupplySchemeVO.getApplicationSubmitType());
        proPowerSupplySchemeEntity.setApplicationSubmitExplain(reqUpdatePowerSupplySchemeVO.getApplicationSubmitExplain());
        proPowerSupplySchemeEntity.setCustomerManager(reqUpdatePowerSupplySchemeVO.getCustomerManager());
        proPowerSupplySchemeEntity.setCustomerEngineer(reqUpdatePowerSupplySchemeVO.getCustomerEngineer());


        proPowerSupplySchemeEntity.setPowerSupplyDiagram(reqUpdatePowerSupplySchemeVO.getPowerSupplyDiagram());
        proPowerSupplySchemeEntity.setPowerSupplyFinal(reqUpdatePowerSupplySchemeVO.getPowerSupplyFinal());
        proPowerSupplySchemeEntity.setEnclosureFile(reqUpdatePowerSupplySchemeVO.getEnclosureFile());


        Date date = new Date();
        proPowerSupplySchemeEntity.setCreateTime(date);
        proPowerSupplySchemeEntity.setUpdateTime(date);
        proPowerSupplySchemeEntity.setStatus(1);
        proPowerSupplySchemeEntity.setIdProPowerSupplyScheme(reqUpdatePowerSupplySchemeVO.getIdProPowerSupplyScheme());
        proPowerSupplySchemeDao.updateById(proPowerSupplySchemeEntity);

        if(ParametersUtil.isNotNull(reqUpdatePowerSupplySchemeVO.getPowerSupplyDiagram())){
            uploadService.updateFileStatus(reqUpdatePowerSupplySchemeVO.getPowerSupplyDiagram());
        }
        if(ParametersUtil.isNotNull(reqUpdatePowerSupplySchemeVO.getPowerSupplyFinal())) {
            uploadService.updateFileStatus(reqUpdatePowerSupplySchemeVO.getPowerSupplyFinal());
        }
        if(ParametersUtil.isNotNull(reqUpdatePowerSupplySchemeVO.getEnclosureFile())) {
            uploadService.updateFileStatus(reqUpdatePowerSupplySchemeVO.getEnclosureFile());
        }

        Wrapper wrapper = new EntityWrapper<ProPowerSupplySchemeElectricityPriceAssEntity>();
        if(ParametersUtil.isNotNull(reqUpdatePowerSupplySchemeVO.getProPowerSupplySchemeElectricityPriceList()) && reqUpdatePowerSupplySchemeVO.getProPowerSupplySchemeElectricityPriceList().size() > 0){
            wrapper.eq("idx_pro_power_supply_scheme",reqUpdatePowerSupplySchemeVO.getIdProPowerSupplyScheme());
            proPowerSupplySchemeElectricityPriceAssDao.delete(wrapper);
            for (ReqProPowerSupplySchemeElectricityPriceAssVO reqProPowerSupplySchemeElectricityPriceAssVO : reqUpdatePowerSupplySchemeVO.getProPowerSupplySchemeElectricityPriceList()) {
                ProPowerSupplySchemeElectricityPriceAssEntity proPowerSupplySchemeElectricityPriceAssEntity = new ProPowerSupplySchemeElectricityPriceAssEntity();
                proPowerSupplySchemeElectricityPriceAssEntity.setIdxProPowerSupplyScheme(proPowerSupplySchemeEntity.getIdProPowerSupplyScheme());
                proPowerSupplySchemeElectricityPriceAssEntity.setElectricityPriceOne(reqProPowerSupplySchemeElectricityPriceAssVO.getElectricityPriceOne());
                proPowerSupplySchemeElectricityPriceAssEntity.setElectricityPriceTwo(reqProPowerSupplySchemeElectricityPriceAssVO.getElectricityPriceTwo());
                proPowerSupplySchemeElectricityPriceAssEntity.setElectricityPriceStandard(reqProPowerSupplySchemeElectricityPriceAssVO.getElectricityPriceStandard());
                proPowerSupplySchemeElectricityPriceAssDao.insert(proPowerSupplySchemeElectricityPriceAssEntity);
            }
        }

        wrapper = new EntityWrapper<ProPowerSupplySchemeMeteringAssEntity>();
        if(ParametersUtil.isNotNull(reqUpdatePowerSupplySchemeVO.getProPowerSupplySchemeMeteringList()) && reqUpdatePowerSupplySchemeVO.getProPowerSupplySchemeMeteringList().size() > 0) {
            wrapper.eq("idx_pro_power_supply_scheme", reqUpdatePowerSupplySchemeVO.getIdProPowerSupplyScheme());
            proPowerSupplySchemeMeteringAssDao.delete(wrapper);
            for (ReqProPowerSupplySchemeMeteringAssVO reqProPowerSupplySchemeMeteringAssVO : reqUpdatePowerSupplySchemeVO.getProPowerSupplySchemeMeteringList()) {
                ProPowerSupplySchemeMeteringAssEntity proPowerSupplySchemeMeteringAssEntity = new ProPowerSupplySchemeMeteringAssEntity();
                proPowerSupplySchemeMeteringAssEntity.setIdxProPowerSupplyScheme(proPowerSupplySchemeEntity.getIdProPowerSupplyScheme());
                proPowerSupplySchemeMeteringAssEntity.setMeteringSpotCount(reqProPowerSupplySchemeMeteringAssVO.getMeteringSpotCount());
                proPowerSupplySchemeMeteringAssEntity.setInstallationLocation(reqProPowerSupplySchemeMeteringAssVO.getInstallationLocation());
                proPowerSupplySchemeMeteringAssEntity.setDataCommunicationWay(reqProPowerSupplySchemeMeteringAssVO.getDataCommunicationWay());
                proPowerSupplySchemeMeteringAssEntity.setMeteringWay(reqProPowerSupplySchemeMeteringAssVO.getMeteringWay());
                proPowerSupplySchemeMeteringAssEntity.setConnectionMode(reqProPowerSupplySchemeMeteringAssVO.getConnectionMode());
                proPowerSupplySchemeMeteringAssEntity.setMeteringSpotVoltage(reqProPowerSupplySchemeMeteringAssVO.getMeteringSpotVoltage());
                proPowerSupplySchemeMeteringAssEntity.setTerminalType(reqProPowerSupplySchemeMeteringAssVO.getTerminalType());
                proPowerSupplySchemeMeteringAssEntity.setEnergyMeterType(reqProPowerSupplySchemeMeteringAssVO.getEnergyMeterType());
                proPowerSupplySchemeMeteringAssEntity.setEnergyMeterVoltage(reqProPowerSupplySchemeMeteringAssVO.getEnergyMeterVoltage());
                proPowerSupplySchemeMeteringAssEntity.setEnergyMeterElectric(reqProPowerSupplySchemeMeteringAssVO.getEnergyMeterElectric());
                proPowerSupplySchemeMeteringAssEntity.setEnergyMeterAccuracy(reqProPowerSupplySchemeMeteringAssVO.getEnergyMeterAccuracy());
                proPowerSupplySchemeMeteringAssEntity.setVoltageMutualInductorVoltage(reqProPowerSupplySchemeMeteringAssVO.getVoltageMutualInductorVoltage());
                proPowerSupplySchemeMeteringAssEntity.setVoltageMutualInductorVariableRatio(reqProPowerSupplySchemeMeteringAssVO.getVoltageMutualInductorVariableRatio());
                proPowerSupplySchemeMeteringAssEntity.setVoltageMutualInductorAccuracy(reqProPowerSupplySchemeMeteringAssVO.getVoltageMutualInductorAccuracy());
                proPowerSupplySchemeMeteringAssEntity.setVoltageMutualInductorCount(reqProPowerSupplySchemeMeteringAssVO.getVoltageMutualInductorCount());
                proPowerSupplySchemeMeteringAssEntity.setElectricMutualInductorVoltage(reqProPowerSupplySchemeMeteringAssVO.getElectricMutualInductorVoltage());
                proPowerSupplySchemeMeteringAssEntity.setElectricMutualInductorVariableRatio(reqProPowerSupplySchemeMeteringAssVO.getElectricMutualInductorVariableRatio());
                proPowerSupplySchemeMeteringAssEntity.setElectricMutualInductorAccuracy(reqProPowerSupplySchemeMeteringAssVO.getElectricMutualInductorAccuracy());
                proPowerSupplySchemeMeteringAssEntity.setElectricMutualInductorCount(reqProPowerSupplySchemeMeteringAssVO.getElectricMutualInductorCount());
                proPowerSupplySchemeMeteringAssEntity.setMeteringTerminalLocation(reqProPowerSupplySchemeMeteringAssVO.getMeteringTerminalLocation());
                proPowerSupplySchemeMeteringAssEntity.setMeteringTerminalAccuracy(reqProPowerSupplySchemeMeteringAssVO.getMeteringTerminalAccuracy());
                proPowerSupplySchemeMeteringAssEntity.setMeteringTerminalCount(reqProPowerSupplySchemeMeteringAssVO.getMeteringTerminalCount());
                proPowerSupplySchemeMeteringAssDao.insert(proPowerSupplySchemeMeteringAssEntity);
            }
        }

        wrapper = new EntityWrapper<ProPowerSupplySchemePowerAssEntity>();
        if(ParametersUtil.isNotNull(reqUpdatePowerSupplySchemeVO.getProPowerSupplySchemePowerAssList()) && reqUpdatePowerSupplySchemeVO.getProPowerSupplySchemePowerAssList().size() > 0) {
            wrapper.eq("idx_pro_power_supply_scheme", reqUpdatePowerSupplySchemeVO.getIdProPowerSupplyScheme());
            proPowerSupplySchemePowerAssDao.delete(wrapper);
            for (ReqProPowerSupplySchemePowerAssVO reqProPowerSupplySchemePowerAssVO : reqUpdatePowerSupplySchemeVO.getProPowerSupplySchemePowerAssList()) {
                ProPowerSupplySchemePowerAssEntity proPowerSupplySchemePowerAssEntity = new ProPowerSupplySchemePowerAssEntity();
                proPowerSupplySchemePowerAssEntity.setIdxProPowerSupplyScheme(proPowerSupplySchemeEntity.getIdProPowerSupplyScheme());
                proPowerSupplySchemePowerAssEntity.setPowerSupply(reqProPowerSupplySchemePowerAssVO.getPowerSupply());
                proPowerSupplySchemePowerAssEntity.setPowerProperties(reqProPowerSupplySchemePowerAssVO.getPowerProperties());
                proPowerSupplySchemePowerAssEntity.setPowerType(reqProPowerSupplySchemePowerAssVO.getPowerType());
                proPowerSupplySchemePowerAssEntity.setPowerSpot(reqProPowerSupplySchemePowerAssVO.getPowerSpot());
                proPowerSupplySchemePowerAssEntity.setPowerVoltage(reqProPowerSupplySchemePowerAssVO.getPowerVoltage());
                proPowerSupplySchemePowerAssEntity.setPowerCapacity(reqProPowerSupplySchemePowerAssVO.getPowerCapacity());
                proPowerSupplySchemePowerAssEntity.setLineParameters1(reqProPowerSupplySchemePowerAssVO.getLineParameters1());
                proPowerSupplySchemePowerAssEntity.setLineParameters2(reqProPowerSupplySchemePowerAssVO.getLineParameters2());
                proPowerSupplySchemePowerAssEntity.setLayingMethod(reqProPowerSupplySchemePowerAssVO.getLayingMethod());
                proPowerSupplySchemePowerAssEntity.setGroundingMode(reqProPowerSupplySchemePowerAssVO.getGroundingMode());
                proPowerSupplySchemePowerAssEntity.setShortCircuitCapacity(reqProPowerSupplySchemePowerAssVO.getShortCircuitCapacity());
                proPowerSupplySchemePowerAssEntity.setPointPropertyRight(reqProPowerSupplySchemePowerAssVO.getPointPropertyRight());
                proPowerSupplySchemePowerAssDao.insert(proPowerSupplySchemePowerAssEntity);
            }
        }

        ProPowerSupplySchemeEntity proPowerSupplySchemeEntity1 = proPowerSupplySchemeDao.selectById(reqUpdatePowerSupplySchemeVO.getIdProPowerSupplyScheme());

        if(ParametersUtil.isNotNull(reqUpdatePowerSupplySchemeVO.getSubmitState())){
            addOrUpdateProStatus(proPowerSupplySchemeEntity1.getIdxProAdmin(),ProjectStatus.POWER_SUPPLY_SCHEME.getValue(),reqUpdatePowerSupplySchemeVO.getSubmitState());
        }

        if(reqUpdatePowerSupplySchemeVO.getSubmitState()!=null && reqUpdatePowerSupplySchemeVO.getSubmitState() ==3 ){
            updateStatus(proPowerSupplySchemeEntity1.getIdxProAdmin());
        }else if(reqUpdatePowerSupplySchemeVO.getSubmitState()!=null && !(reqUpdatePowerSupplySchemeVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqUpdatePowerSupplySchemeVO.getSubmitState());
            proAdmin.setIdProAdmin(proPowerSupplySchemeEntity1.getIdxProAdmin());
            proAdminDao.updateById(proAdmin);
        }


        return 1;

    }

    /**
     * 获取供电方案信息
     *
     * @param reqGetPowerSupplySchemeInfoVO
     * @return
     */
    @Override
    public ResGetPowerSupplySchemeInfoVO getPowerSupplySchemeInfo(ReqGetPowerSupplySchemeInfoVO reqGetPowerSupplySchemeInfoVO) {
        ResGetPowerSupplySchemeInfoVO resGetPowerSupplySchemeInfoVO = proIntervalApprovalDao.getPowerSupplySchemeInfo(reqGetPowerSupplySchemeInfoVO);
        resGetPowerSupplySchemeInfoVO.setProPowerSupplySchemeElectricityPriceList(proPowerSupplySchemeElectricityPriceAssDao.getProPowerSupplySchemeElectricityPriceList(resGetPowerSupplySchemeInfoVO.getIdProPowerSupplyScheme()));
        resGetPowerSupplySchemeInfoVO.setProPowerSupplySchemeMeteringList(proPowerSupplySchemeMeteringAssDao.getProPowerSupplySchemeMeteringList(resGetPowerSupplySchemeInfoVO.getIdProPowerSupplyScheme()));
        resGetPowerSupplySchemeInfoVO.setProPowerSupplySchemePowerAssList(proPowerSupplySchemePowerAssDao.getProPowerSupplySchemePowerAssList(resGetPowerSupplySchemeInfoVO.getIdProPowerSupplyScheme()));

        ProStatusInfoAssEntity proStatus = getProStatus(resGetPowerSupplySchemeInfoVO.getIdProAdmin(), ProjectStatus.POWER_SUPPLY_SCHEME.getValue());
        resGetPowerSupplySchemeInfoVO.setStatus(proAdminDao.selectById(resGetPowerSupplySchemeInfoVO.getIdProAdmin()).getStatus().getValue());
        resGetPowerSupplySchemeInfoVO.setSubmitState(proStatus.getSubmitState());
        return resGetPowerSupplySchemeInfoVO;
    }

    /**
     * 获取项目基本信息
     *
     * @param reqGetProjectBaseInfoVO
     * @return
     */
    @Override
    public ResGetProjectBaseInfoVO getProjectBaseInfo(ReqGetProjectBaseInfoVO reqGetProjectBaseInfoVO) {
        return proAdminDao.getProjectBaseInfo(reqGetProjectBaseInfoVO);
    }

    /**
     * 添加供电方案
     *
     * @param reqAddUserEvaluationVO
     * @return
     */
    @Override
    @Transactional
    public Integer addUserEvaluation(ReqAddUserEvaluationVO reqAddUserEvaluationVO) {
        ProUserEvaluationEntity proUserEvaluationEntity = new ProUserEvaluationEntity();
        proUserEvaluationEntity.setIdxProAdmin(reqAddUserEvaluationVO.getIdProAdmin());
        proUserEvaluationEntity.setCustomerEvaluation(reqAddUserEvaluationVO.getCustomerEvaluation());
        uploadService.updateFileStatus(reqAddUserEvaluationVO.getCustomerEvaluation());
        proUserEvaluationEntity.setStatus(1);
        Date date = new Date();
        proUserEvaluationEntity.setCreateTime(date);
        proUserEvaluationEntity.setUpdateTime(date);
        proUserEvaluationDao.insert(proUserEvaluationEntity);


        addOrUpdateProStatus(reqAddUserEvaluationVO.getIdProAdmin(),ProjectStatus.USER_EVALUATION.getValue(),reqAddUserEvaluationVO.getSubmitState());

        if(reqAddUserEvaluationVO.getSubmitState()!=null && reqAddUserEvaluationVO.getSubmitState() ==3 ){
            updateStatus(reqAddUserEvaluationVO.getIdProAdmin());
        }else if( !(reqAddUserEvaluationVO.getSubmitState()!=null && reqAddUserEvaluationVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqAddUserEvaluationVO.getSubmitState());
            proAdmin.setIdProAdmin(reqAddUserEvaluationVO.getIdProAdmin());
            proAdminDao.updateById(proAdmin);
        }
        return 1;
    }

    /**
     * 修改供电方案
     *
     * @param reqUpdateUserEvaluationVO
     * @return
     */
    @Override
    @Transactional
    public Integer updateUserEvaluation(ReqUpdateUserEvaluationVO reqUpdateUserEvaluationVO) {
        ProUserEvaluationEntity proUserEvaluationEntity = new ProUserEvaluationEntity();
        proUserEvaluationEntity.setCustomerEvaluation(reqUpdateUserEvaluationVO.getCustomerEvaluation());
        uploadService.updateFileStatus(reqUpdateUserEvaluationVO.getCustomerEvaluation());
        Date date = new Date();
        proUserEvaluationEntity.setUpdateTime(date);
        proUserEvaluationEntity.setIdProUserEvaluation(reqUpdateUserEvaluationVO.getIdProUserEvaluation());
        proUserEvaluationDao.updateById(proUserEvaluationEntity);

        ProUserEvaluationEntity proUserEvaluationEntity1 = proUserEvaluationDao.selectById(reqUpdateUserEvaluationVO.getIdProUserEvaluation());
        addOrUpdateProStatus(proUserEvaluationEntity1.getIdxProAdmin(),ProjectStatus.USER_EVALUATION.getValue(),reqUpdateUserEvaluationVO.getSubmitState());

        if(reqUpdateUserEvaluationVO.getSubmitState()!=null && reqUpdateUserEvaluationVO.getSubmitState() ==3 ){
            updateStatus(proUserEvaluationEntity1.getIdxProAdmin());
        }else if( !(reqUpdateUserEvaluationVO.getSubmitState()!=null && reqUpdateUserEvaluationVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqUpdateUserEvaluationVO.getSubmitState());
            proAdmin.setIdProAdmin(proUserEvaluationEntity1.getIdxProAdmin());
            proAdminDao.updateById(proAdmin);
        }
        return 1;
    }

    /**
     * 获取用户评价信息
     *
     * @param reqGetUserEvaluationInfoVO
     * @return
     */
    @Override
    public ResGetUserEvaluationInfoVO getUserEvaluationInfo(ReqGetUserEvaluationInfoVO reqGetUserEvaluationInfoVO) {
        ProUserEvaluationEntity wrapper = new ProUserEvaluationEntity();
        wrapper.setIdxProAdmin(reqGetUserEvaluationInfoVO.getIdProAdmin());
        ProUserEvaluationEntity proUserEvaluationEntity = proUserEvaluationDao.selectOne(wrapper);
        ResGetUserEvaluationInfoVO resGetUserEvaluationInfoVO = new ResGetUserEvaluationInfoVO();
        resGetUserEvaluationInfoVO.setIdProAdmin(proUserEvaluationEntity.getIdxProAdmin());
        resGetUserEvaluationInfoVO.setCustomerEvaluation(proUserEvaluationEntity.getCustomerEvaluation());
        SysFilesEntity sysFilesEntity = sysFilesDao.selectById(proUserEvaluationEntity.getCustomerEvaluation());
        resGetUserEvaluationInfoVO.setCustomerEvaluationFileName(sysFilesEntity.getFileName());
        resGetUserEvaluationInfoVO.setCustomerEvaluationFilePath(sysFilesEntity.getFilePath());
        resGetUserEvaluationInfoVO.setCustomerEvaluationSuffixName(sysFilesEntity.getSuffixName());
        resGetUserEvaluationInfoVO.setIdProUserEvaluation(proUserEvaluationEntity.getIdProUserEvaluation());

        ProStatusInfoAssEntity proStatusInfoAssEntity = getProStatus(proUserEvaluationEntity.getIdxProAdmin(),ProjectStatus.USER_EVALUATION.getValue());
        resGetUserEvaluationInfoVO.setStatus(proStatusInfoAssEntity.getStatus());
        resGetUserEvaluationInfoVO.setSubmitState(proStatusInfoAssEntity.getSubmitState());
        return resGetUserEvaluationInfoVO;
    }

    /**
     * 添加资料归档
     *
     * @param reqAddDataArchivingVO
     * @return
     */
    @Override
    @Transactional
    public Integer addDataArchiving(ReqAddDataArchivingVO reqAddDataArchivingVO) {
        ProDataArchivingEntity proDataArchivingEntity = new ProDataArchivingEntity();
        proDataArchivingEntity.setIdxProAdmin(reqAddDataArchivingVO.getIdProAdmin());
        proDataArchivingEntity.setStatus(1);
        proDataArchivingEntity.setDataArchivingState(reqAddDataArchivingVO.getDataArchivingState());
        proDataArchivingEntity.setHandoverList(reqAddDataArchivingVO.getHandoverList());
        uploadService.updateFileStatus(reqAddDataArchivingVO.getHandoverList());
        Date date = new Date();
        proDataArchivingEntity.setCreateTime(date);
        proDataArchivingEntity.setUpdateTime(date);
        proDataArchivingDao.insert(proDataArchivingEntity);

        addOrUpdateProStatus(reqAddDataArchivingVO.getIdProAdmin(),ProjectStatus.DATA_ARCHIVING.getValue(),reqAddDataArchivingVO.getSubmitState());

        if(reqAddDataArchivingVO.getSubmitState()!=null && reqAddDataArchivingVO.getSubmitState() ==3 ){
            updateStatus(reqAddDataArchivingVO.getIdProAdmin());
        }else if( !(reqAddDataArchivingVO.getSubmitState()!=null && reqAddDataArchivingVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqAddDataArchivingVO.getSubmitState());
            proAdmin.setIdProAdmin(reqAddDataArchivingVO.getIdProAdmin());
            proAdminDao.updateById(proAdmin);
        }

        return 1;
    }

    /**
     * 修改资料归档
     *
     * @param reqUpdateDataArchivingVO
     * @return
     */
    @Override
    @Transactional
    public Integer updateDataArchiving(ReqUpdateDataArchivingVO reqUpdateDataArchivingVO) {
        ProDataArchivingEntity proDataArchivingEntity = new ProDataArchivingEntity();
        proDataArchivingEntity.setStatus(1);
        proDataArchivingEntity.setDataArchivingState(reqUpdateDataArchivingVO.getDataArchivingState());
        proDataArchivingEntity.setHandoverList(reqUpdateDataArchivingVO.getHandoverList());
        proDataArchivingEntity.setIdProDataArchiving(reqUpdateDataArchivingVO.getIdProDataArchiving());
        Date date = new Date();
        proDataArchivingEntity.setUpdateTime(date);
        uploadService.updateFileStatus(reqUpdateDataArchivingVO.getHandoverList());
        proDataArchivingEntity.setIdProDataArchiving(reqUpdateDataArchivingVO.getIdProDataArchiving());
        proDataArchivingDao.updateById(proDataArchivingEntity);

        ProDataArchivingEntity wrapper = new ProDataArchivingEntity();
        wrapper.setIdProDataArchiving(reqUpdateDataArchivingVO.getIdProDataArchiving());
        ProDataArchivingEntity proDataArchivingEntity1 = proDataArchivingDao.selectOne(wrapper);
        addOrUpdateProStatus(proDataArchivingEntity1.getIdxProAdmin(),ProjectStatus.DATA_ARCHIVING.getValue(),reqUpdateDataArchivingVO.getSubmitState());

        if(reqUpdateDataArchivingVO.getSubmitState()!=null && reqUpdateDataArchivingVO.getSubmitState() ==3 ){
            updateStatus(proDataArchivingEntity1.getIdxProAdmin());
        }else if( !(reqUpdateDataArchivingVO.getSubmitState()!=null && reqUpdateDataArchivingVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqUpdateDataArchivingVO.getSubmitState());
            proAdmin.setIdProAdmin(proDataArchivingEntity1.getIdxProAdmin());
            proAdminDao.updateById(proAdmin);
        }

        return 1;
    }

    /**
     * 获取资料归档信息
     *
     * @param reqGetDataArchivingInfoVO
     * @return
     */
    @Override
    public ResGetDataArchivingInfoVO getDataArchivingInfo(ReqGetDataArchivingInfoVO reqGetDataArchivingInfoVO) {
        ProDataArchivingEntity wrapper = new ProDataArchivingEntity();
        wrapper.setIdxProAdmin(reqGetDataArchivingInfoVO.getIdProAdmin());
        ProDataArchivingEntity proDataArchivingEntity = proDataArchivingDao.selectOne(wrapper);
        ResGetDataArchivingInfoVO resGetDataArchivingInfoVO = new ResGetDataArchivingInfoVO();
        resGetDataArchivingInfoVO.setIdProAdmin(proDataArchivingEntity.getIdxProAdmin());
        resGetDataArchivingInfoVO.setIdProDataArchiving(proDataArchivingEntity.getIdProDataArchiving());
        resGetDataArchivingInfoVO.setDataArchivingState(proDataArchivingEntity.getDataArchivingState());
        resGetDataArchivingInfoVO.setHandoverList(proDataArchivingEntity.getHandoverList());
        SysFilesEntity sysFilesEntity = sysFilesDao.selectById(proDataArchivingEntity.getHandoverList());
        resGetDataArchivingInfoVO.setHandoverListFileName(sysFilesEntity.getFileName());
        resGetDataArchivingInfoVO.setHandoverListFilePath(sysFilesEntity.getFilePath());
        resGetDataArchivingInfoVO.setHandoverListSuffixName(sysFilesEntity.getSuffixName());

        //获取项目状态
        ProStatusInfoAssEntity proStatusInfoAssEntity = getProStatus(reqGetDataArchivingInfoVO.getIdProAdmin(),
                ProjectStatus.DATA_ARCHIVING.getValue());
        resGetDataArchivingInfoVO.setStatus(proStatusInfoAssEntity.getStatus());
        resGetDataArchivingInfoVO.setSubmitState(proStatusInfoAssEntity.getSubmitState());
        return resGetDataArchivingInfoVO;
    }

    /**
     * 添加现场勘查
     *
     * @param reqAddSceneInvestigationVO
     * @return
     */
    @Override
    @Transactional
    public Integer addSceneInvestigation(ReqAddSceneInvestigationVO reqAddSceneInvestigationVO) {
        ProSceneInvestigationEntity proSceneInvestigationEntity = new ProSceneInvestigationEntity();
        proSceneInvestigationEntity.setIdxProAdmin(reqAddSceneInvestigationVO.getIdProAdmin());
        proSceneInvestigationEntity.setIdxUserBaseInfo(reqAddSceneInvestigationVO.getUserId());
        proSceneInvestigationEntity.setPowerSupplyVoltage(reqAddSceneInvestigationVO.getPowerSupplyVoltage());
        proSceneInvestigationEntity.setElectricityCharacteristic(reqAddSceneInvestigationVO.getElectricityCharacteristic());
        proSceneInvestigationEntity.setLoadType(reqAddSceneInvestigationVO.getLoadType());
        proSceneInvestigationEntity.setLineLaying(reqAddSceneInvestigationVO.getLineLaying());
        proSceneInvestigationEntity.setApplyCapacity(reqAddSceneInvestigationVO.getApplyCapacity());
        proSceneInvestigationEntity.setForceStandard(reqAddSceneInvestigationVO.getForceStandard());

        proSceneInvestigationEntity.setLatitude(reqAddSceneInvestigationVO.getLatitude());
        proSceneInvestigationEntity.setLongitude(reqAddSceneInvestigationVO.getLongitude());
        proSceneInvestigationEntity.setAltitude(reqAddSceneInvestigationVO.getAltitude());

        ProAdminEntity proAdminEntity = new ProAdminEntity();
        proAdminEntity.setLatitude(reqAddSceneInvestigationVO.getLatitude());
        proAdminEntity.setLongitude(reqAddSceneInvestigationVO.getLongitude());
        proAdminEntity.setAltitude(reqAddSceneInvestigationVO.getAltitude());
        proAdminEntity.setIdProAdmin(reqAddSceneInvestigationVO.getIdProAdmin());
        proAdminDao.updateById(proAdminEntity);

        proSceneInvestigationEntity.setSceneVerificationCapacityKw(reqAddSceneInvestigationVO.getSceneVerificationCapacityKw());
        proSceneInvestigationEntity.setSceneVerificationCapacityKva(reqAddSceneInvestigationVO.getSceneVerificationCapacityKva());
        proSceneInvestigationEntity.setSceneTotalCapacity(reqAddSceneInvestigationVO.getSceneTotalCapacity());
        proSceneInvestigationEntity.setOpenCapacity(reqAddSceneInvestigationVO.getOpenCapacity());
        proSceneInvestigationEntity.setPowerSupplyScheme(reqAddSceneInvestigationVO.getPowerSupplyScheme());
        proSceneInvestigationEntity.setMeasurementScheme(reqAddSceneInvestigationVO.getMeasurementScheme());
        proSceneInvestigationEntity.setExplorers(reqAddSceneInvestigationVO.getExplorers());
        proSceneInvestigationEntity.setExplorersTime(reqAddSceneInvestigationVO.getExplorersTime());
        proSceneInvestigationEntity.setOther(reqAddSceneInvestigationVO.getOther());
        proSceneInvestigationEntity.setCustomerSign(reqAddSceneInvestigationVO.getCustomerSign());
        proSceneInvestigationEntity.setStatus(1);
        Date date = DateUtil.nowDate();
        proSceneInvestigationEntity.setCreateTime(date);
        proSceneInvestigationEntity.setUpdateTime(date);
        proSceneInvestigationDao.insert(proSceneInvestigationEntity);

        uploadService.updateFileStatus(Long.parseLong(reqAddSceneInvestigationVO.getCustomerSign()));

        addOrUpdateProStatus(reqAddSceneInvestigationVO.getIdProAdmin(),ProjectStatus.SCENE_INVESTIGATION.getValue(),reqAddSceneInvestigationVO.getSubmitState());

        if(reqAddSceneInvestigationVO.getSubmitState()!=null && reqAddSceneInvestigationVO.getSubmitState() ==3 ){
            updateStatus(reqAddSceneInvestigationVO.getIdProAdmin());
        }else if( !(reqAddSceneInvestigationVO.getSubmitState()!=null && reqAddSceneInvestigationVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqAddSceneInvestigationVO.getSubmitState());
            proAdmin.setIdProAdmin(reqAddSceneInvestigationVO.getIdProAdmin());
            proAdminDao.updateById(proAdmin);
        }
        return 1;
    }

    /**
     * 修改现场勘查
     *
     * @param reqUpdateSceneInvestigationVO
     * @return
     */
    @Override
    @Transactional
    public Integer updateSceneInvestigation(ReqUpdateSceneInvestigationVO reqUpdateSceneInvestigationVO) {
        ProSceneInvestigationEntity proSceneInvestigationEntity = new ProSceneInvestigationEntity();
        proSceneInvestigationEntity.setPowerSupplyVoltage(reqUpdateSceneInvestigationVO.getPowerSupplyVoltage());
        proSceneInvestigationEntity.setElectricityCharacteristic(reqUpdateSceneInvestigationVO.getElectricityCharacteristic());
        proSceneInvestigationEntity.setLoadType(reqUpdateSceneInvestigationVO.getLoadType());
        proSceneInvestigationEntity.setLineLaying(reqUpdateSceneInvestigationVO.getLineLaying());
        proSceneInvestigationEntity.setApplyCapacity(reqUpdateSceneInvestigationVO.getApplyCapacity());
        proSceneInvestigationEntity.setForceStandard(reqUpdateSceneInvestigationVO.getForceStandard());

        proSceneInvestigationEntity.setLatitude(reqUpdateSceneInvestigationVO.getLatitude());
        proSceneInvestigationEntity.setLongitude(reqUpdateSceneInvestigationVO.getLongitude());
        proSceneInvestigationEntity.setAltitude(reqUpdateSceneInvestigationVO.getAltitude());

        ProSceneInvestigationEntity wrapper = new ProSceneInvestigationEntity();
        wrapper.setIdProSceneInvestigation(reqUpdateSceneInvestigationVO.getIdProSceneInvestigation());
        ProSceneInvestigationEntity proSceneInvestigationEntity1 = proSceneInvestigationDao.selectOne(wrapper);

        ProAdminEntity proAdminEntity = new ProAdminEntity();
        proAdminEntity.setLatitude(reqUpdateSceneInvestigationVO.getLatitude());
        proAdminEntity.setLongitude(reqUpdateSceneInvestigationVO.getLongitude());
        proAdminEntity.setAltitude(reqUpdateSceneInvestigationVO.getAltitude());
        proAdminEntity.setIdProAdmin(proSceneInvestigationEntity1.getIdxProAdmin());
        proAdminDao.updateById(proAdminEntity);

        proSceneInvestigationEntity.setSceneVerificationCapacityKw(reqUpdateSceneInvestigationVO.getSceneVerificationCapacityKw());
        proSceneInvestigationEntity.setSceneVerificationCapacityKva(reqUpdateSceneInvestigationVO.getSceneVerificationCapacityKva());
        proSceneInvestigationEntity.setSceneTotalCapacity(reqUpdateSceneInvestigationVO.getSceneTotalCapacity());
        proSceneInvestigationEntity.setOpenCapacity(reqUpdateSceneInvestigationVO.getOpenCapacity());
        proSceneInvestigationEntity.setPowerSupplyScheme(reqUpdateSceneInvestigationVO.getPowerSupplyScheme());
        proSceneInvestigationEntity.setMeasurementScheme(reqUpdateSceneInvestigationVO.getMeasurementScheme());
        proSceneInvestigationEntity.setExplorers(reqUpdateSceneInvestigationVO.getExplorers());
        proSceneInvestigationEntity.setExplorersTime(reqUpdateSceneInvestigationVO.getExplorersTime());
        proSceneInvestigationEntity.setOther(reqUpdateSceneInvestigationVO.getOther());
        proSceneInvestigationEntity.setCustomerSign(ParametersUtil.isNull(reqUpdateSceneInvestigationVO.getCustomerSign())?null:reqUpdateSceneInvestigationVO.getCustomerSign().toString());
        proSceneInvestigationEntity.setStatus(1);
        Date date = DateUtil.nowDate();
        proSceneInvestigationEntity.setUpdateTime(date);
        proSceneInvestigationEntity.setIdProSceneInvestigation(reqUpdateSceneInvestigationVO.getIdProSceneInvestigation());
        proSceneInvestigationDao.updateById(proSceneInvestigationEntity);


        addOrUpdateProStatus(proSceneInvestigationEntity1.getIdxProAdmin(),ProjectStatus.SCENE_INVESTIGATION.getValue(),reqUpdateSceneInvestigationVO.getSubmitState());
        if(reqUpdateSceneInvestigationVO.getSubmitState()!=null && reqUpdateSceneInvestigationVO.getSubmitState() ==3 ){
            updateStatus(proSceneInvestigationEntity1.getIdxProAdmin());
        }else if( !(reqUpdateSceneInvestigationVO.getSubmitState()!=null && reqUpdateSceneInvestigationVO.getSubmitState() == 0) ){
            ProAdminEntity proAdmin = new ProAdminEntity();
            proAdmin.setSubmitState(reqUpdateSceneInvestigationVO.getSubmitState());
            proAdmin.setIdProAdmin(proSceneInvestigationEntity1.getIdxProAdmin());
            proAdminDao.updateById(proAdmin);
        }
        return 1;
    }

    /**
     * 获取检查验收列表
     *
     * @param reqGetIntermediateInspectionListVO
     * @return
     */
    @Override
    public PageInfo<ResGetProjectListVO> getIntermediateInspectionList(ReqGetIntermediateInspectionListVO reqGetIntermediateInspectionListVO) {
        PageInfo<ResGetProjectListVO> pageInfo = new PageInfo<>(reqGetIntermediateInspectionListVO);
        List<ResGetProjectListVO> list = proReExaminationDao.getIntermediateInspectionList(pageInfo,reqGetIntermediateInspectionListVO);

        for (ResGetProjectListVO resGetProjectListVO : list) {
            Wrapper<ProReExaminationEntity> wrapperCount = new EntityWrapper<>();
            wrapperCount.eq("idx_pro_admin",resGetProjectListVO.getIdProAdmin());
            wrapperCount.eq("test_type",reqGetIntermediateInspectionListVO.getTestType());
            Integer count = proReExaminationDao.selectCount(wrapperCount);
            resGetProjectListVO.setCount1(count);
            /*if(reqGetIntermediateInspectionListVO.getStatus()!=null) {
                ProStatusInfoAssEntity proStatusInfoAssEntity = getProStatus(resGetProjectListVO.getIdProAdmin(),
                        reqGetIntermediateInspectionListVO.getStatus().getValue());
                resGetProjectListVO.setStatus(proStatusInfoAssEntity.getStatus());
                resGetProjectListVO.setSubmitState(proStatusInfoAssEntity.getSubmitState());
            }*/
        }
        pageInfo.setData(list);
        pageInfo.setTotalResult(proReExaminationDao.getIntermediateInspectionListTotalCount(reqGetIntermediateInspectionListVO));
        return pageInfo;
    }

    /**
     * 获取现场勘查信息
     *
     * @param reqGetSceneInvestigationInfoVO
     * @return
     */
    @Override
    public ResGetSceneInvestigationInfoVO getSceneInvestigationInfo(ReqGetSceneInvestigationInfoVO reqGetSceneInvestigationInfoVO) {
        ResGetSceneInvestigationInfoVO resGetSceneInvestigationInfoVO = proReExaminationDao.getSceneInvestigationInfo(reqGetSceneInvestigationInfoVO);

        ProStatusInfoAssEntity proStatus = getProStatus(reqGetSceneInvestigationInfoVO.getIdProAdmin(), ProjectStatus.SCENE_INVESTIGATION.getValue());
        resGetSceneInvestigationInfoVO.setStatus(proAdminDao.selectById(reqGetSceneInvestigationInfoVO.getIdProAdmin()).getStatus().getValue());
        resGetSceneInvestigationInfoVO.setSubmitState(proStatus.getSubmitState());
        return resGetSceneInvestigationInfoVO;
    }

    /**
     * 添加竣工资料收集
     *
     * @param reqAddCompletionDataCollectionVO
     * @return
     */
    @Override
    @Transactional
    public Integer addCompletionDataCollection(ReqAddCompletionDataCollectionVO reqAddCompletionDataCollectionVO) {
        ProAdminEntity proAdminEntity = proAdminDao.selectById(reqAddCompletionDataCollectionVO.getIdProAdmin());
        ProStatusInfoAssEntity intervalApprovalStatus = getProStatus(reqAddCompletionDataCollectionVO.getIdProAdmin(),ProjectStatus.INTERVAL_APPROVAL.getValue());
        ProStatusInfoAssEntity applicationForDoubleNumberStatus = getProStatus(reqAddCompletionDataCollectionVO.getIdProAdmin(),ProjectStatus.APPLICATION_FOR_DOUBLE_NUMBER.getValue());
        ProStatusInfoAssEntity doubleNumberingStatus = getProStatus(reqAddCompletionDataCollectionVO.getIdProAdmin(),ProjectStatus.DOUBLE_NUMBERING.getValue());
        ProStatusInfoAssEntity informStatus = getProStatus(reqAddCompletionDataCollectionVO.getIdProAdmin(),ProjectStatus.INFORM.getValue());
        ProStatusInfoAssEntity blackoutAndFireStatus = getProStatus(reqAddCompletionDataCollectionVO.getIdProAdmin(),ProjectStatus.BLACKOUT_AND_FIRE.getValue());
        ProStatusInfoAssEntity protectionFixedValueReportingStatus = getProStatus(reqAddCompletionDataCollectionVO.getIdProAdmin(),ProjectStatus.PROTECTION_FIXED_VALUE_REPORTING.getValue());
        ProStatusInfoAssEntity intermediateInspectionStatus = getProStatus(reqAddCompletionDataCollectionVO.getIdProAdmin(),ProjectStatus.INTERMEDIATE_INSPECTION.getValue());
        if(intervalApprovalStatus.getSubmitState() != 3 && proAdminEntity.getFunIntervalApprovalState() == 1){
            throw new ServerException(RespEnum.REQUEST_PARAM_ERROR,"间隔审批未提交");
        }else if(applicationForDoubleNumberStatus.getSubmitState() != 3 && proAdminEntity.getFunDoubleHeavyState() == 1){
            throw new ServerException(RespEnum.REQUEST_PARAM_ERROR,"申请双重编号未提交");
        }else if(doubleNumberingStatus.getSubmitState() != 3){
            throw new ServerException(RespEnum.REQUEST_PARAM_ERROR,"下达双重编号未提交");
        }else if(informStatus.getSubmitState() != 3 && proAdminEntity.getFunInformState() == 1){
            throw new ServerException(RespEnum.REQUEST_PARAM_ERROR,"告知未提交");
        }else if(blackoutAndFireStatus.getSubmitState() != 3 ){
            throw new ServerException(RespEnum.REQUEST_PARAM_ERROR,"停电接火未提交");
        }else if(protectionFixedValueReportingStatus.getSubmitState() != 3 && proAdminEntity.getFunFixedValuePresentationState() == 1){
            throw new ServerException(RespEnum.REQUEST_PARAM_ERROR,"保护定值报送未提交");
        }else if(intermediateInspectionStatus.getSubmitState() != 3){
            throw new ServerException(RespEnum.REQUEST_PARAM_ERROR,"竣工资料收集未提交");
        }
        addOrUpdateProStatus(reqAddCompletionDataCollectionVO.getIdProAdmin(),ProjectStatus.COMPLETION_DATA_COLLECTION.getValue(),3);
        ProAdminEntity proAdmin = new ProAdminEntity();
        proAdmin.setSubmitState(0);
        proAdmin.setStatus(ProjectStatus.COMPLETION_ACCEPTANCE);
        proAdmin.setIdProAdmin(reqAddCompletionDataCollectionVO.getIdProAdmin());
        Date date = DateUtil.nowDate();
        proAdmin.setUpdateTime(date);
        proAdminDao.updateById(proAdmin);
        return 1;
    }


}
